Is it possible to constrain the residual variance in MLwiN?

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
erikruzek
Posts: 12
Joined: Tue May 21, 2019 3:57 pm

Is it possible to constrain the residual variance in MLwiN?

Post by erikruzek »

Hi all,

I am running a longitudinal model on an outcome that was measured and scored using a 1-PL IRT model (Rasch). For each observation of the outcome, there is an associated standard error of measurement (SEM). Is it possible to fix or constrain the residual variance in a MLwiN model (via runmlwin or R2MLwiN) based on the SEM (I would use SEM^2)? I know this is doable in the HLM program, but I would much prefer to do this analysis in MLwiN.

Thanks,
Erik
ChrisCharlton
Posts: 1248
Joined: Mon Oct 19, 2009 10:34 am

Re: Is it possible to constrain the residual variance in MLwiN?

Post by ChrisCharlton »

runmlwin follows the Stata syntax for defining constraints. See this previous post from George for some details:

viewtopic.php?t=773

For another example using runmlwin and R2MLwiN see Chapter 18 of the MLwiN User Guide replication examples:

runmlwin: https://www.bristol.ac.uk/cmm/software/ ... /examples/

R2MLwiN: https://www.bristol.ac.uk/cmm/software/ ... /examples/
erikruzek
Posts: 12
Joined: Tue May 21, 2019 3:57 pm

Re: Is it possible to constrain the residual variance in MLwiN?

Post by erikruzek »

Hi George,

Thanks so much.

In the example you linked, the residual variance was set at a single value (scalar).

Code: Select all

constraint define 1 [RP1]var(cons) = 0.5
I would like to set the residual variance to a variable in the dataset given that the SEM is unique to each observation in the data.

Code: Select all

constraint define 1 [RP1]var(cons) = sem
Doing so gives me the following error:

Code: Select all

. runmlwin RIT time_a time_asq coho2 timea_coho2 timeasq_coho2 cons , level2(STUDENT_GRD_KEY: cons time_a time_asq) level
> 1(obs2: cons) nopause constraints(1) sd corr 
 
(note: constraint number 1 caused error r(111))
matrix e(Cns) not found
r(111);
Is it that I need to create a vector defined by the sem? Sorry if my terminology is off.
ChrisCharlton
Posts: 1248
Joined: Mon Oct 19, 2009 10:34 am

Re: Is it possible to constrain the residual variance in MLwiN?

Post by ChrisCharlton »

Sorry, I misunderstood that you wanted to constrain the residual error variance rather than the residual variances themselves.

I had a brief discussion with George about this and he thinks that it might be possible through adding a pseudo level-1 for your s.e. measurements with a variance constrained to one. It would however be useful if you could provide the example that you have for doing this with HLM so that we can confirm the approach taken.
GeorgeLeckie
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: Is it possible to constrain the residual variance in MLwiN?

Post by GeorgeLeckie »

Hi Erik,

This would be my guess at what you want to do...
Think you want to specify a three-level model. So shift the usual two-level growth-curve model up to level-2 and level-3
Observations (level-1) within observations (level-2) within persons (level-3)
Then at the new level-1 you enter the constrained variance.
First make sure you have a variable in your dataset which stores the SEs associated with the predicted scores from the IRT model
Then make this variable random at level-1
Then constrain the variance of this variable to equal 1.

So something like...

. constraint define [RP1]var(sevariable) = 1
. runmlwin y cons time, level3(person: cons time) level2(obs: cons) level1(obs: sevariable) constraints(1)

You mention that you can do what you want in HLM. If there is an example dataset and output floating about on the net it would be good you first trying to replicate that to check that the above approach works. Actually, if you pass on the reference we will try to take a look too.

Best wishes

George
erikruzek
Posts: 12
Joined: Tue May 21, 2019 3:57 pm

Re: Is it possible to constrain the residual variance in MLwiN?

Post by erikruzek »

Thanks, Chris and George.

George, I am having trouble locating a web example from HLM. My colleague said that that it involves the fixsigma2 command (setting it to 1) and then specifying a "varianceknown" variable. Below is a snippet of code from a HLM syntax file. It looks like something similar as you proposed is going on. I cannot find information on the varianceknown command in HLM's documentation.

Code: Select all

fixsigma2:1.000000
fixtau2:3
fixtau3:3
accel:5
level1weight:none
level2weight:none
level3weight:none
varianceknown:SEM2
Regarding your suggestion, is the obs variable specified for level2 and level1 the same variable?

Although the suggested model runs, the random slope(s), covariance(s) between the random slope(s) and intercept, and the level2 observation variance are not estimated.
Post Reply