Message/Author 

empisoz posted on Tuesday, June 02, 2020  9:04 am



Dear all, I am wondering how to model the residual withingroup variance of a twolevel model usign withingroup covariates. The betweengroup part is readily available from ex9.28 (the random residual variance). However, it is not clear to me how to model the withingroup part per se. I think one would need (a) to transform the residual withingroup variance using the log of the withingrouup 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? 


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. 


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. You should read this first http://statmodel.com/download/webnotes/mc3.pdf 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. 

Back to top 