Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Stata runs very slow when estimating mixed models in a multiple imputed database

    Dear Statalisters, I am using mixedin Stata 13 to assess the effect of a treatment on four different measures of physical activity in a randomised trial. The problem is that the models run very slowly, often more than 45 minutes before rendering an output, if they report an output at all.

    My database has over 1300 cases, and it is multiple imputed, with the multiple imputation command mi generating 50 imputed datasets. The dependent variable is Activity (continuous), and the model adjusts it by a number of covariates, both continuous and categorical, and the baseline value of the dependent variable Activity_b. The model also includes 3 fixed effects: treatment (with values 1,2,3), centre (with values 1,2,3,4 for the participating sites) and frailty (with categories frail, pre-frail and no frail), and one random effect defined by Couple - to account for cluster-randomisation of individuals in a couple to the same treatment .

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double Activity byte treatment double centre float frailty double Activity_b int Couple 
                    . 2 1 2 682.0952380952385  1
                    . 2 1 1 732.4722222222217  2
    739.7619047619044 2 1 1 669.7380952380956  2
    853.2222222222217 1 1 1 870.5714285714286  4
    622.2619047619044 3 1 1 588.6666666666671  5
                    . 1 1 2 699.5476190476186  6
                    . 3 1 1  631.305555555555  7
    805.8809523809529 1 1 1 737.3095238095242  8
                    . 2 1 1 739.2380952380956  9
                    . 2 1 1  644.305555555555 10
                    . 2 1 1 697.2857142857143 10
    788.5714285714286 3 1 1 768.8809523809529 12
    766.7857142857143 1 1 0 761.0476190476186 13
    640.4047619047615 2 1 0 657.7857142857143 14
                    . 3 1 0 695.6666666666671 15
                    . 3 1 2 714.7619047619044 16
    793.3095238095242 3 1 0 776.2619047619044 17
      746.97619047619 3 1 0 751.0714285714286 17
                    . 2 1 2 799.3333333333329 19
                    . 2 1 0               845 20
    end
    label values frailty frailty_lbl
    label def frailty_lbl 0 "No frail", modify
    label def frailty_lbl 1 "Pre-frail", modify
    label def frailty_lbl 2 "Frail", modify

    The command is
    Code:
    mi estimate: mixed Activity i.treatment i.centre i.frailty $cov Activity_b || Couple:, residuals (independent, by (centre))
    where cov is the list of covariates defined as global:
    Code:
    global cov "covariate1 covariate2 covariate3"
    I've tried it in two different computers (Stata 13 and Stata15.1), and the models run extremely slow in both. What can you suggest to increase the speed of estimation?

    Thanks a lot !

    Marta

  • #2
    Welcome to Statalist.

    Use the newest version of Stata that you can, with the most powerful computer you can get.

    But personally I don't think 45 minutes for a job that combines mixed with 50 multiple imputations is very bad at all, at least by Stata standards. That is less than a minute for each imputed data set. I've seen people run models for days and even a week.

    If I don't want to wait while jobs run, I often run them on another computer, e.g. if I am at home I will have my office machine run it, and vice-versa. Also, I have the option to send monster jobs off to unix machines that are off in the distance.

    You might also consider doing fewer imputations. Once you have finalized your models, you can rerun them with more imputations if you want.
    -------------------------------------------
    Richard Williams, Notre Dame Dept of Sociology
    StataNow Version: 19.5 MP (2 processor)

    EMAIL: [email protected]
    WWW: https://www3.nd.edu/~rwilliam

    Comment


    • #3
      Thanks a lot for your reply Williams ! I'll get patient with my poor slow computer. :-)

      Marta

      Comment

      Working...
      X