## How to constrain the lowest level variance to 1

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/
frankpeter
Posts: 4
Joined: Sat Sep 03, 2011 4:53 pm

### How to constrain the lowest level variance to 1

Dear All,

I am trying to replicate example of multilevel approach to meta-analysis using runmlwin (http://www.ats.ucla.edu/stat/MLwiN/exam ... apter8.htm).
Please, how can I constrain the lowest level of variance to one.

Thanks.

Frank

GeorgeLeckie
Posts: 352
Joined: Fri Apr 01, 2011 2:14 pm

### Re: How to constrain the lowest level variance to 1

Dear Frank,

Consider the first model presented in:

http://www.ats.ucla.edu/stat/mlwin/exam ... apter8.htm

To replicate this model using runmlwin you need the following

Code: Select all

`use "http://www.ats.ucla.edu/stat/stata/examples/mlm_ma_hox/meta20", clearreplace study = 17 if _n==17constraint define 1 [RP1]var(stderr) = 1generate cons = 1generate stderr = sqrt(varofd)runmlwin d cons, ///   level2(study: cons) ///   level1(d: stderr) ///   constraints(1) ///   mlwinsettings(size(100)) ///   nopause `

where:

(1) the replace command is used to correct a data error in the original data (Study 17 was mistakenly given an ID of 16 rather than 17)

(2) we use Stata's constraint define command to constrain the level-1 variance to a value of one

(3) we use constraints(1) option of the runmlwin command to attach the constraint to the model.

One oddity that we hope to fix in a later release is that we have had to use the mlwinsettings(size(100)) option to manually tell MLwiN how big a worksheet it will need. Normally runmlwin works out how big a worksheet you need and there is no need for a manual override. Here you do need to manually override here due to the unusual dimensions of the worksheet (there is a very high ratio of variables to observations).

If you fit this model you should see the following output

Code: Select all

`. use "http://www.ats.ucla.edu/stat/stata/examples/mlm_ma_hox/meta20", clear. . replace study = 17 if _n==17(1 real change made). . constraint define 1 [RP1]var(stderr) = 1. . generate cons = 1. . generate stderr = sqrt(varofd). . runmlwin d cons, ///>         level2(study: cons) ///>         level1(d: stderr) ///>         constraints(1) ///>         mlwinsettings(size(100)) ///>         nopause   ( 1)  [RP1]var(stderr) = 1MLwiN 2.24 multilevel model                     Number of obs      =        20Normal response modelEstimation algorithm: IGLS-----------------------------------------------------------                |   No. of       Observations per Group Level Variable |   Groups    Minimum    Average    Maximum----------------+------------------------------------------          study |       20          1        1.0          1-----------------------------------------------------------Run time (seconds)   =       1.23Number of iterations =          4Log likelihood       = -13.899582Deviance             =  27.799164------------------------------------------------------------------------------           d |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]-------------+----------------------------------------------------------------        cons |   .5790381   .1049019     5.52   0.000     .3734342    .7846419------------------------------------------------------------------------------------------------------------------------------------------------------------   Random-effects Parameters |   Estimate   Std. Err.     [95% Conf. Interval]-----------------------------+------------------------------------------------Level 2: study               |                   var(cons) |   .1315565   .0692808     -.0042314    .2673444-----------------------------+------------------------------------------------Level 1: d                   |                 var(stderr) |          1          0             1           1------------------------------------------------------------------------------`

Let us know how you get on with replicating the other models

Best wishes

George
*************************
George Leckie
runmlwin developer
Centre for Multilevel Modelling
*************************

frankpeter
Posts: 4
Joined: Sat Sep 03, 2011 4:53 pm

### Re: How to constrain the lowest level variance to 1

Dear George,

Thanks for the prompt and for sending the code. That is exactly what I am looking for you. Please, I run the code, I got the following error message:

estimates post: matrix has missing values
Warning - runmlwin has experienced difficulties importing the standard errors, all standard errors have been set to zero
Warning: getversion plugin could not be loaded

I am using
- Stata 12/IC
- MLwiN 2.24
- runmlwin.ado, George Leckie and Chris Charlton, 01Dec2011

Thanks

Frank Peter

Code: Select all

` use "http://www.ats.ucla.edu/stat/stata/examples/mlm_ma_hox/meta20", clear. replace study = 17 if _n==17(1 real change made). constraint define 1 [RP1]var(stderr) = 1. generate cons = 1. generate stderr = sqrt(varofd). runmlwin d cons, ///> level2(study: cons) ///> level1(d: stderr) ///> constraints(1) ///> mlwinsettings(size(100)) ///> nopause   ( 1)  [RP1]var(stderr) = 1estimates post: matrix has missing valuesWarning - runmlwin has experienced difficulties importing the standard errors, all standard errors have been set to zeroWarning: getversion plugin could not be loadedMLwiN ... multilevel model                      Number of obs      =        20Normal response modelEstimation algorithm: IGLS-----------------------------------------------------------                |   No. of       Observations per Group Level Variable |   Groups    Minimum    Average    Maximum----------------+------------------------------------------          study |       20          1        1.0          1-----------------------------------------------------------Run time (seconds)   =       2.75Number of iterations =          4Log likelihood       = -13.899582Deviance             =  27.799164------------------------------------------------------------------------------           d |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]-------------+----------------------------------------------------------------        cons |   .5790381          0        .      .      .5790381    .5790381------------------------------------------------------------------------------------------------------------------------------------------------------------   Random-effects Parameters |   Estimate   Std. Err.     [95% Conf. Interval]-----------------------------+------------------------------------------------Level 2: study               |                   var(cons) |   .1315565          0      .1315565    .1315565-----------------------------+------------------------------------------------Level 1: d                   |                 var(stderr) |          1          0             1           1------------------------------------------------------------------------------. end of do-file`

GeorgeLeckie
Posts: 352
Joined: Fri Apr 01, 2011 2:14 pm

### Re: How to constrain the lowest level variance to 1

Hi Peter,

Apologies, the current release version of runmlwin (which you are using) has a small bug relating to the standard errors of model parameters when constraints are used.

We have fixed this on our development version and I will email you a copy of this so you can proceed with your analysis.

The next release of runmlwin will be out early January. If anyone else wants the bug fixed version before then, please contact me.

Best wishes

George
*************************
George Leckie
runmlwin developer
Centre for Multilevel Modelling
*************************

frankpeter
Posts: 4
Joined: Sat Sep 03, 2011 4:53 pm

### Re: How to constrain the lowest level variance to 1

Hi George,

Thanks for the prompt reply. It worked fine.

Peter