Page 1 of 1

Different results in Stata and MLwiN for random intercept linear regression

Posted: Wed Jul 15, 2015 2:17 pm
by kjetilwel
Dear all,
I am using runmlwin to estimate a simple 2-level linear random intercept model. While the Stata commands xtreg and xtmixed produce comparable results, the MlwiN results differ dramatically. Compared to the Stata results the fixed effects are similar, but the coefficients for the level2 variable is different and with a much larger standard error. Furthermore, while xtmixed report a variance of 0.19, the level2 variance in MLwiN is 55.99, which does not make sense! This is puzzling because the runmlwin help file says that the command I am using should be analogue to xtreg.

These are the commands I am running:

runmlwin depvar Level2var level1covars , level2(groupvar: cons) level1(PID: cons) nopause

xtreg depvar Level2var level1covars, i(groupvar)

xtmixed depvar Level2var level1covars || groupvar: , mle

Does anyone have an explanation?

Many thanks,
Kjetil van der Wel

Re: Different results in Stata and MLwiN for random intercept linear regression

Posted: Wed Jul 15, 2015 8:09 pm
by ChrisCharlton
By default xtmixed (and presumably xtreg) display random effects as standard deviations, whereas runmlwin reports these as variances. Both commands have options to change this.

Code: Select all

. use http://www.bristol.ac.uk/cmm/media/runmlwin/tutorial, clear

Code: Select all

. xtreg normexam standlrt, i(school)

Random-effects GLS regression                   Number of obs     =      4,059
Group variable: school                          Number of groups  =         65

R-sq:                                           Obs per group:
     within  = 0.3329                                         min =          2
     between = 0.4794                                         avg =       62.4
     overall = 0.3500                                         max =        198

                                                Wald chi2(1)      =    2042.68
corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =     0.0000

------------------------------------------------------------------------------
    normexam |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
    standlrt |   .5636107   .0124704    45.20   0.000     .5391692    .5880522
       _cons |   .0026355   .0388987     0.07   0.946    -.0736046    .0788756
-------------+----------------------------------------------------------------
     sigma_u |  .29374257
     sigma_e |  .75211121
         rho |  .13234743   (fraction of variance due to u_i)
------------------------------------------------------------------------------

Code: Select all

. xtmixed normexam standlrt || school: , mle

Performing EM optimization: 

Performing gradient-based optimization: 

Iteration 0:   log likelihood = -4678.6211  
Iteration 1:   log likelihood = -4678.6211  

Computing standard errors:

Mixed-effects ML regression                     Number of obs     =      4,059
Group variable: school                          Number of groups  =         65

                                                Obs per group:
                                                              min =          2
                                                              avg =       62.4
                                                              max =        198

                                                Wald chi2(1)      =    2042.57
Log likelihood = -4678.6211                     Prob > chi2       =     0.0000

------------------------------------------------------------------------------
    normexam |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
    standlrt |   .5633711   .0124654    45.19   0.000     .5389394    .5878029
       _cons |   .0023907   .0400227     0.06   0.952    -.0760524    .0808338
------------------------------------------------------------------------------

------------------------------------------------------------------------------
  Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
school: Identity             |
                   sd(_cons) |   .3035282   .0305253      .2492271    .3696603
-----------------------------+------------------------------------------------
                sd(Residual) |   .7521508   .0084176      .7358322    .7688313
------------------------------------------------------------------------------
LR test vs. linear model: chibar2(01) = 403.27        Prob >= chibar2 = 0.0000

Code: Select all

. runmlwin normexam cons standlrt, level2(school: cons) level1(student: cons) nopause sd
 
MLwiN 2.34 multilevel model                     Number of obs      =      4059
Normal response model
Estimation algorithm: IGLS

-----------------------------------------------------------
                |   No. of       Observations per Group
 Level Variable |   Groups    Minimum    Average    Maximum
----------------+------------------------------------------
         school |       65          2       62.4        198
-----------------------------------------------------------

Run time (seconds)   =       2.09
Number of iterations =          4
Log likelihood       = -4678.6211
Deviance             =  9357.2422
------------------------------------------------------------------------------
    normexam |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        cons |   .0023908   .0400224     0.06   0.952    -.0760516    .0808332
    standlrt |   .5633712   .0124654    45.19   0.000     .5389394    .5878029
------------------------------------------------------------------------------

------------------------------------------------------------------------------
   Random-effects Parameters |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
Level 2: school              |
                    sd(cons) |   .3035252   .0298946      .2378215    .3573458
-----------------------------+------------------------------------------------
Level 1: student             |
                    sd(cons) |   .7521509   .0084149      .7354732    .7684668
------------------------------------------------------------------------------

Code: Select all

. xtmixed normexam standlrt || school: , mle var

Performing EM optimization: 

Performing gradient-based optimization: 

Iteration 0:   log likelihood = -4678.6211  
Iteration 1:   log likelihood = -4678.6211  

Computing standard errors:

Mixed-effects ML regression                     Number of obs     =      4,059
Group variable: school                          Number of groups  =         65

                                                Obs per group:
                                                              min =          2
                                                              avg =       62.4
                                                              max =        198

                                                Wald chi2(1)      =    2042.57
Log likelihood = -4678.6211                     Prob > chi2       =     0.0000

------------------------------------------------------------------------------
    normexam |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
    standlrt |   .5633711   .0124654    45.19   0.000     .5389394    .5878029
       _cons |   .0023907   .0400227     0.06   0.952    -.0760524    .0808338
------------------------------------------------------------------------------

------------------------------------------------------------------------------
  Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
school: Identity             |
                  var(_cons) |   .0921294   .0185306      .0621141    .1366488
-----------------------------+------------------------------------------------
               var(Residual) |   .5657309   .0126626      .5414491    .5911016
------------------------------------------------------------------------------
LR test vs. linear model: chibar2(01) = 403.27        Prob >= chibar2 = 0.0000

Code: Select all

. runmlwin normexam cons standlrt, level2(school: cons) level1(student: cons) nopause
 
MLwiN 2.34 multilevel model                     Number of obs      =      4059
Normal response model
Estimation algorithm: IGLS

-----------------------------------------------------------
                |   No. of       Observations per Group
 Level Variable |   Groups    Minimum    Average    Maximum
----------------+------------------------------------------
         school |       65          2       62.4        198
-----------------------------------------------------------

Run time (seconds)   =       2.40
Number of iterations =          4
Log likelihood       = -4678.6211
Deviance             =  9357.2422
------------------------------------------------------------------------------
    normexam |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        cons |   .0023908   .0400224     0.06   0.952    -.0760516    .0808332
    standlrt |   .5633712   .0124654    45.19   0.000     .5389394    .5878029
------------------------------------------------------------------------------

------------------------------------------------------------------------------
   Random-effects Parameters |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
Level 2: school              |
                   var(cons) |   .0921275   .0181475      .0565591     .127696
-----------------------------+------------------------------------------------
Level 1: student             |
                   var(cons) |    .565731   .0126585      .5409209    .5905412
------------------------------------------------------------------------------
Would this explain what you were seeing?

Re: Different results in Stata and MLwiN for random intercept linear regression

Posted: Thu Jul 16, 2015 9:49 am
by kjetilwel
Dear Chris,
Thanks for your reply. I did know about the difference in the xtmixed and MLwiN reporting. Your code did however help me anyway because it made me realise that I (embarrassingly) had overlooked that the constant term needs be included explicitly in the code!

Thanks,
Kjetil