fix level 1 variance

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/
Post Reply
emily123
Posts: 2
Joined: Wed Jul 03, 2013 9:46 am

fix level 1 variance

Post by emily123 »

Hi,
I wish to fit a random coefficient model with unstructured covariance, where I can fix the level 1 random effects parameter, sigma e, to a specific value using prior knowledge obtained from a different dataset.
I can fit the same model using xtmixed and runmlwin for both IGLS and MCMC. I don't believe I can fix any parameters in Stata, but was wondering if it is possible using runmlwin?
Any advice would be much appreciated, thanks!
best wishes, Emily
GeorgeLeckie
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: fix level 1 variance

Post by GeorgeLeckie »

Hi Emily,

It is very easy to specify constraints with runmlwin. Below is an example where we constrain the level-1 residual error variance to be 0.5

Best wishes

George

Code: Select all

use http://www.bristol.ac.uk/cmm/media/runmlwin/tutorial, clear
runmlwin normexam cons standlrt, level2(school: cons) level1(student: cons) nopause
constraint define 1 [RP1]var(cons) = 0.5
runmlwin normexam cons standlrt, level2(school: cons) level1(student: cons) nopause constraints(1)

Code: Select all

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

. runmlwin normexam cons standlrt, level2(school: cons) level1(student: cons) nopause
 
MLwiN 2.27 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)   =       1.71
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      .5409208    .5905412
------------------------------------------------------------------------------

. constraint define 1 [RP1]var(cons) = 0.5

. runmlwin normexam cons standlrt, level2(school: cons) level1(student: cons) nopause constraints(1)
 
 ( 1)  [RP1]var(cons) = .5
MLwiN 2.27 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)   =       1.51
Number of iterations =          4
Log likelihood       = -4694.4922
Deviance             =  9388.9844
------------------------------------------------------------------------------
    normexam |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        cons |   .0018578   .0401241     0.05   0.963    -.0767839    .0804995
    standlrt |    .562891   .0117265    48.00   0.000     .5399075    .5858745
------------------------------------------------------------------------------

------------------------------------------------------------------------------
   Random-effects Parameters |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
Level 2: school              |
                   var(cons) |   .0939082   .0182508      .0581373    .1296792
-----------------------------+------------------------------------------------
Level 1: student             |
                   var(cons) |         .5          0            .5          .5
------------------------------------------------------------------------------
GeorgeLeckie
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: fix level 1 variance

Post by GeorgeLeckie »

Hi Emily,

You also said " I don't believe I can fix any parameters in Stata". You can in Stata 13 using the -me- suite of commands.

Code: Select all

use http://www.bristol.ac.uk/cmm/media/runmlwin/tutorial, clear
constraint define 1 _b[var(e.normexam):_cons] = 0.5
meglm normexam standlrt || school:, constraints(1)
and you will get the following output

Code: Select all

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

. constraint define 1 _b[var(e.normexam):_cons] = 0.5

. meglm normexam standlrt || school:, constraints(1)

Fitting fixed-effects model:

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

Refining starting values:

Grid node 0:   log likelihood = -4698.6738

Fitting full model:

Iteration 0:   log likelihood = -4698.6738  
Iteration 1:   log likelihood = -4694.5823  
Iteration 2:   log likelihood = -4694.4925  
Iteration 3:   log likelihood = -4694.4924  

Mixed-effects GLM                               Number of obs      =      4059
Family:                Gaussian
Link:                  identity
Group variable:          school                 Number of groups   =        65

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

Integration method: mvaghermite                 Integration points =         7

                                                Wald chi2(1)       =   2297.55
Log likelihood = -4694.4924                     Prob > chi2        =    0.0000
 ( 1)  [var(e.normexam)]_cons = .5
--------------------------------------------------------------------------------
      normexam |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
---------------+----------------------------------------------------------------
      standlrt |    .562891   .0117434    47.93   0.000     .5398744    .5859075
         _cons |   .0018577    .040131     0.05   0.963    -.0767976     .080513
---------------+----------------------------------------------------------------
school         |
     var(_cons)|    .093909   .0186238                      .0636647     .138521
---------------+----------------------------------------------------------------
var(e.normexam)|         .5  (constrained)
--------------------------------------------------------------------------------
emily123
Posts: 2
Joined: Wed Jul 03, 2013 9:46 am

Re: fix level 1 variance

Post by emily123 »

Thanks so much for your quick reply - very helpful, and very simple! Sorry I missed this in all the documentation/do files.
best wishes, Emily
Post Reply