Multiple imputation with RealCom and runmlwin

Welcome to the forum for runmlwin users. Feel free to post your question about runmlwin here. The Centre for Multilevel Modelling take no responsibility for the accuracy of these posts, we are unable to monitor them closely. Do go ahead and post your question and thank you in advance if you find the time to post any answers!

Go to runmlwin: Running MLwiN from within Stata >> http://www.bristol.ac.uk/cmm/software/runmlwin/
Jamoo
Posts: 36
Joined: Wed Oct 05, 2011 2:33 pm

Multiple imputation with RealCom and runmlwin

Post by Jamoo »

Dear users,

I have used runmlwin to successfully run some random intercept and slope models with my data (thanks so much for the mlwin user manual translations - they were invaluable).

I'm using realcom to impute some of my datasets. Does runmlwin have the capability to run the multiple imputation commands in mlwin - e.g. through the Model-Imputation-retrieve menu path?

Thanks

Jamie
GeorgeLeckie
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: Multiple imputation with RealCom and runmlwin

Post by GeorgeLeckie »

Hi Jamie,

Really great question.

No we haven't implemented those particular MLwiN options. The reason for this is that you should be able to do what you want rather simply as follows:

You can use the realcomimpute Stata command to call RealCom from Stata

You can then use the mi: prefix with the runmlwin command to fit your multilevel model of interest in MLwiN to the multiple "complete" data sets and to then combine the estimates using Rubin's Rules.

Note that realcomimpute is written by Jonathan Bartlett at London School of Hygiene & Tropical Medicine (see http://www.missingdata.org.uk/).

Best wishes

George
Jamoo
Posts: 36
Joined: Wed Oct 05, 2011 2:33 pm

Re: Multiple imputation with RealCom and runmlwin

Post by Jamoo »

Hi George,

Thanks for the reply. I meant to ask whether the mi: prefix would work. That's great news.

I'll make sure to reference Jonathan, yourself and all the others involved in making all these programmes work together. It's really a god send.

Best wishes

Jamie
GeorgeLeckie
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: Multiple imputation with RealCom and runmlwin

Post by GeorgeLeckie »

Thanks for your feedback Jamie,
Do let us know how you get on
Best wishes
George
Jamoo
Posts: 36
Joined: Wed Oct 05, 2011 2:33 pm

Re: Multiple imputation with RealCom and runmlwin

Post by Jamoo »

Hi all,

Happy New Year!

The multiple imputation with mi: seems to work fine - thanks for the advice on this George.

For reference on the list, the code I used was as follows:
NB: the DeleteRandomEffects.do deletes variables from then random effects models created by previous runmlwin commands
NB: the mi est command needs the cmdok option to run user-written commands like runmlwin (see below for where to insert it in the code and please let me know if I'm wrong on this)
cd "Drive and Directory with imputed files\"
capture drop _merge
realcomImputeLoad
mi set wide
mi register regular deltabmi bmi1c
do "Analysis/Repetitive Code/DeleteRandomEffects.do"
mi est, cmdok: runmlwin deltabmi cons bmi1c asian black, ///
level2(numprogid: cons, residuals(u)) level1(pid: cons) nopause
Best wishes

Jamie
GeorgeLeckie
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: Multiple imputation with RealCom and runmlwin

Post by GeorgeLeckie »

Hi Jamie,

That's great. I'm glad you got it working.

Thanks also for posting your solution, that will be very helpful for other users

Best wishes

George
Jamoo
Posts: 36
Joined: Wed Oct 05, 2011 2:33 pm

Re: Multiple imputation with RealCom and runmlwin

Post by Jamoo »

Hi all,

Is there any way that using mi est: etc.. with Stata to combine the estimates might be different from that obtained with MlWin?

My random parameters are identical when I fit the models in both datasets. However, there is some quite substantial variation in the overall intercept and the coefficients. For example, a coefficient which is 0.041 in MLwiN is 0.073 in Stata.

Best wishes

Jamie
GeorgeLeckie
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: Multiple imputation with RealCom and runmlwin

Post by GeorgeLeckie »

Hi Jamie,

On reason for why you might see different results is if your underlying imputed data sets differ.

This will likely happen if you have run REALCOM twice (perhaps once via the MLwiN drop-down menus and once via the -realcomimpute- command in Stata).

So I think you first want to check that you are using exactly the same imputed data sets when fitting your model of interest to the multiply imputed data sets in MLwiN and in runmlwin.

Best wishes

George
drsatpalsandhu
Posts: 7
Joined: Tue Oct 29, 2013 12:14 pm

Re: Multiple imputation with RealCom and runmlwin

Post by drsatpalsandhu »

Hi George and Jamie,
I was thinking about the same i.e how to combine runmlwin, REALCOM imput and MLwiN.
The thing is that i can do multiple imputations using REALCOM impute through realcomimpute Stata command and could successfully use mi estimate: xtmixed..... in stata to analyze multiple imputed data-sets.

Similarly, for the same model without imputation, i can use runmlwin to analyse the data using MLwiN.

However, when i try to use runmlwin with multiple imputed data sets by using mi est, cmdok: runmlwin............ i get a message "an error occurred when mi estimate executed runmlwin on m=1". I used commands as mentioned by Jamie in one of the previous post.

Can you please help me to find out where i might be going wrong.

Thanks..
Sandhu
GeorgeLeckie
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: Multiple imputation with RealCom and runmlwin

Post by GeorgeLeckie »

HI,

Not sure what the problem might be.

The following MI estimation example gives the same results whether we use Stata or MLwiN. Does this example work for you?

Code: Select all

. * Load data
. webuse mheart1s20, clear
(Fictional heart attack data; bmi missing)

. 
. * Describe the multiply imputed datasets
. mi describe

  Style:  mlong
          last mi update 07feb2013 13:05:30, 108 days ago

  Obs.:   complete          132
          incomplete         22  (M = 20 imputations)
          ---------------------
          total             154

  Vars.:  imputed:  1; bmi(22)

          passive:  0

          regular:  5; attack smokes age female hsgrad

          system:   3; _mi_m _mi_id _mi_miss

         (there are no unregistered variables)

. 
. * Fit the model in Stata to 5 imputed data sets and combine results using 
. * Rubin rules
. mi estimate, dots imputations(1/5): ///
>   logit attack smokes age bmi hsgrad female

Imputations (5):
  ..... done

Multiple-imputation estimates                     Imputations     =          5
Logistic regression                               Number of obs   =        154
                                                  Average RVI     =     0.0199
                                                  Largest FMI     =     0.0681
DF adjustment:   Large sample                     DF:     min     =     916.90
                                                          avg     =   49952.59
                                                          max     =  129082.06
Model F test:       Equal FMI                     F(   5,29420.2) =       3.63
Within VCE type:          OIM                     Prob > F        =     0.0028

------------------------------------------------------------------------------
      attack |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      smokes |   1.202657    .357493     3.36   0.001     .5019743    1.903339
         age |   .0352666   .0153952     2.29   0.022      .005092    .0654413
         bmi |   .1050579   .0466256     2.25   0.024     .0135527    .1965631
      hsgrad |   .1597515   .4031809     0.40   0.692    -.6304761     .949979
      female |  -.1122599   .4176527    -0.27   0.788    -.9308943    .7063745
       _cons |  -5.453259   1.635375    -3.33   0.001    -8.659595   -2.246923
------------------------------------------------------------------------------

. 
. * Fit the model using runmlwin to 5 imputed data sets and combine results 
. * using Rubin rules
. gen id = _n

. gen cons = 1

. mi estimate, cmdok dots imputations(1/5): ///
>   runmlwin attack smokes age bmi hsgrad female cons, ///
>     level1(id:) discrete(dist(binomial) link(logit) denom(cons)) nopause

Imputations (5):
  ..... done

Multiple-imputation estimates                     Imputations     =          5
Binomial logit response model                     Number of obs   =        154
                                                  Average RVI     =          .
                                                  Largest FMI     =          .
DF adjustment:   Large sample                     DF:     min     =     915.29
                                                          avg     =          .
                                                          max     =          .

------------------------------------------------------------------------------
             |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
FP1          |
      smokes |   1.202655   .3573613     3.37   0.001     .5022305     1.90308
         age |   .0352665   .0153891     2.29   0.022     .0051039    .0654292
         bmi |   .1050578   .0466062     2.25   0.024     .0135904    .1965251
      hsgrad |   .1597514    .403073     0.40   0.692    -.6302645    .9497674
      female |  -.1122591   .4174906    -0.27   0.788    -.9305758    .7060576
        cons |   -5.45325   1.634382    -3.34   0.001    -8.657642   -2.248858
-------------+----------------------------------------------------------------
OD           |
     bcons_1 |          1          .        .       .            .           .
------------------------------------------------------------------------------
Best wishes

George
Post Reply