3 level multilevel data, multiple imputation, stata, runmlwi

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/
GeorgeLeckie
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: 3 level multilevel data, multiple imputation, stata, run

Post by GeorgeLeckie »

Hi,

We're not sure why you are getting this message. We also get these messages when using mi estimate to fit a two-level continuous response model to five imputed datasets.

"number of groups varies among imputations" suggests that the number of level-2 units varies across the imputed datasets, but we have checked in our example and this is not the case.

"number of observations per group varies among imputations" suggest that the number of level-1 units per level-2 unit variances across the imputed datasets, but this is also not the case.

I think all you can do is to test out -mi estimate- with a simpler model which you can fit using both -mixed- and -runmlwin-. If you get the same combined results, then I think you can safely ignore the error message. In which case you can proceed to use -mi estimate- with -runmlwin- to fit the actual more complex model of interest which can't be fitted using -mixed-.

I hope that helps

George

Best wishes

George
stellaliu
Posts: 8
Joined: Thu Feb 27, 2014 3:05 am

Re: 3 level multilevel data, multiple imputation, stata, run

Post by stellaliu »

I tried to use mi est with both xtmixed and runmlwin to fit an unconditional model, but the results are very different for the random part. See below.

Code: Select all

 mi est: xtmixed POST PRE||_all:R.PID||SCHID:,mle var

Multiple-imputation estimates                   Imputations        =         5
Mixed-effects ML regression                     Number of obs      =      3340

-----------------------------------------------------------
                |   No. of       Observations per Group
 Group Variable |   Groups    Minimum    Average    Maximum
----------------+------------------------------------------
           _all |        1       3340     3340.0       3340
          SCHID |      995          1        3.4         42
-----------------------------------------------------------

                                                Average RVI        =    0.0094
                                                Largest FMI        =    0.0421
DF adjustment:   Large sample                   DF:     min        =   2347.85
                                                        avg        =  1.31e+07
                                                        max        =  5.21e+07
Model F test:       Equal FMI                   F(   1, 5.2e+07)   =    520.26
                                                Prob > F           =    0.0000

------------------------------------------------------------------------------
    POST |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
    PRE |   .2491975   .0109253    22.81   0.000     .2277842    .2706107
       _cons |   .2916921   .0198699    14.68   0.000     .2527277    .3306565
------------------------------------------------------------------------------

------------------------------------------------------------------------------
  Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
_all: Identity               |
                   sd(R.PID) |   .1457662   .0189869      .1129231    .1881615
-----------------------------+------------------------------------------------
SCHID: Identity              |
                   sd(_cons) |   .1165825   .0150739      .0904846    .1502077
-----------------------------+------------------------------------------------
                sd(Residual) |   .5065082   .0067258      .4934958    .5198636
------------------------------------------------------------------------------

Code: Select all

runmlwin POST cons PRE, level3(SCHID: cons) level2(PID: cons) level1(TID: cons) nopause mlwinpath(C:\mlwin.exe) 
estimates store m1igls
mi est,cmdok:runmlwin POST cons PRE, level3(SCHID: cons) level2(PID: cons) level1(TID: cons) mcmc(cc) initsmodel(m1igls) nopause mlwinpath(C:\mlwin.exe)

Multiple-imputation estimates                     Imputations     =          5
Normal response model                             Number of obs   =       3340
                                                  Average RVI     =     0.0098
                                                  Largest FMI     =     0.0442
DF adjustment:   Large sample                     DF:     min     =    2132.40
                                                          avg     =   1.41e+07
                                                          max     =   5.62e+07

------------------------------------------------------------------------------
             |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
FP1          |
        cons |   .2903538   .0194282    14.94   0.000     .2522536     .328454
    PREELNCO |   .2494761   .0110894    22.50   0.000     .2277413    .2712109
-------------+----------------------------------------------------------------
RP3          |
   var(cons) |   .0134291   .0035455     3.79   0.000     .0064801     .020378
-------------+----------------------------------------------------------------
RP2          |
   var(cons) |    .022174    .005766     3.85   0.000     .0108729    .0334751
-------------+----------------------------------------------------------------
RP1          |
   var(cons) |   .2571338   .0069217    37.15   0.000     .2435675       .2707
------------------------------------------------------------------------------
Note: number of groups varies among imputations.
Note: number of observations per group varies among imputations.
GeorgeLeckie
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: 3 level multilevel data, multiple imputation, stata, run

Post by GeorgeLeckie »

Hi,

That's mainly because you are comparing estimated standard deviations (fitted using xtmixed) to estimated variances (runmlwin). If you compare the estimated variances from the two commands they are effectively the same.

There will always be small differences between your two models as you are fitting your xtmixed model my ML, while you are fitting your runmlwin model by MCMC.

You might want to first try establishing that a two-level model fitted using xtmixed and runmlwin using ML and IGLS respectively give the same combined results.

Best wishes

George
lizrichardson
Posts: 4
Joined: Fri Jan 24, 2014 1:59 pm

Re: 3 level multilevel data, multiple imputation, stata, run

Post by lizrichardson »

This suggestion looks promising but I don't have access to the runmlwin.ado file myself (I'm working remotely on a secure setting). Is there a way to get round it to stop the 'model did not converge' error happening in mcmc?
ChrisCharlton wrote:I suspect that the cause of this error is that you are estimating your model of interest with MCMC which doesn't set e(converged) to 1 when it has finished iterating. The mi estimate command checks this returned value before carrying on with running the models. You should be able to work around this by searching for the following line in runmlwin.ado:

Code: Select all

ereturn scalar mcmcdiagnostics = ("`diagnostics'"~="nodiagnostics")
and changing it to:

Code: Select all

ereturn scalar mcmcdiagnostics = ("`diagnostics'"~="nodiagnostics")
ereturn scalar converged = 1
EdwardChau
Posts: 2
Joined: Fri May 29, 2020 1:25 pm

Re: 3 level multilevel data, multiple imputation, stata, run

Post by EdwardChau »

GeorgeLeckie wrote: Mon Feb 10, 2014 12:01 pm Dear Zahra,

Yes, you can use runmlwin with the mi combine prefix in the same way as you would for any other Stata estimation command

The Stata Multiple Imputation manual provides full details

http://www.stata.com/manuals13/mi.pdf

Best wishes

George
Hi George,

Sorry to dig up an old thread, but I have been recently confronted with the same issue. I have a 3-level design with repeated measures of individuals that are grouped into higher-level clusters. I have two outcomes which are continuous they are the only variable with missingness. How would I do a multiple imputation given the nature of this design? Where in that manual does it give examples of how to tackle this?

Thank you!
Post Reply