Page 1 of 1

### Is it possible to constrain the residual variance in MLwiN?

Posted: Mon Feb 01, 2021 10:45 pm
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

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

Posted: Mon Feb 01, 2021 11:04 pm
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/

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

Posted: Tue Feb 02, 2021 12:01 am
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))
r(111);
``````
Is it that I need to create a vector defined by the sem? Sorry if my terminology is off.

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

Posted: Tue Feb 02, 2021 12:38 pm
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.

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

Posted: Tue Feb 02, 2021 1:27 pm
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

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

Posted: Tue Feb 02, 2021 8:04 pm
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.