How to model within-group dispersion
Message/Author
 empisoz posted on Tuesday, June 02, 2020 - 9:04 am
Dear all,
I am wondering how to model the residual within-group variance of a twolevel model usign within-group covariates.
The between-group part is readily available from ex9.28 (the random residual variance). However, it is not clear to me how to model the within-group part per se. I think one would need (a) to transform the residual within-group variance using the log of the within-grouup residual variance and then (b) to relate this tranformed residual variance to the covariates of interest. (a) might be done using model constraint - but such a quantity can't be used in the %within%-part of the model...any suggestions for code?
 Bengt O. Muthen posted on Tuesday, June 02, 2020 - 3:22 pm
You can use the Constraint=x option in the Variable command to provide a variable that can be used in Model Constraint to model the variance using e.g. resvar = exp(a+b*x), where a and b are New parameters and resvar is a parameter labe given in the Model command. We show how to do this in our RMA book.
 empisoz posted on Wednesday, June 03, 2020 - 12:22 pm
thanks a lot, however, it seems that the constraint = X option is not available for TYPE = TWOLEVEL:

*** ERROR in VARIABLE command
Specific constraints for MODEL CONSTRAINT may not be used with TYPE=TWOLEVEL.
 Tihomir Asparouhov posted on Wednesday, June 03, 2020 - 4:12 pm
First note that there is a substantial difference between modeling random residual variance on the between level and doing the same on the within level. For the between level you have multiple observations (i.e. actual sample cluster specific variance can be computed and can be modeled). On the within level you have just one observation that you want to have a subject specific variance. There is no sample quantity that can be computed from just one observation that can then be modeled. Thus - this is much more advanced modeling technique, usually also requiring a large sample.

and if you still think that this is applicable to your situation you can try some coding like this

within=x;

eta by; eta@1;
xe | eta xwith x;
y on xe (b);
y (r);

the combined residual variance for y will be r+x*x*b*b
so it varies as a function of x.
 Ebrahim Hamedi posted on Monday, October 12, 2020 - 6:29 pm
re: the random residual variance

Hi. Bengt mentions that "We show how to do this in our RMA book." unfortunately, I cannot figure where in the book this topic is discussed. can you give me a page number or the title/number of the chapter?

many thanks
 Bengt O. Muthen posted on Tuesday, October 13, 2020 - 3:02 pm
See Section 1.9.6.