Message/Author 

Student 09 posted on Thursday, October 13, 2011  1:07 pm



Hello, I'd like to use the variance of a Level2 factor as Level2 covariate in a twolevel analysis. I tried to create a new variable measuring the Level2 variance of the factor using "Model constraint", but did not succeed. Can anyone post me a syntax example how to put the variance of a L2factor into an independent variable? many thanks! 


The variance of a Level2 factor is a constant and does not vary over the Level2 units (the clusters). Therefore it is not a variable and cannot be a covariate. Perhaps you are thinking of withinlevel variance that varies over the level2 units. 

Student 09 posted on Friday, October 14, 2011  6:45 am



you are rigth  sorry for my error. It is indeed the withingroup variance of a factor I'd like to use as variable (presuming different variance per l2 unit). How would one create such a variable? Please note it is the variance(s) of the factor itself, not the variance of a slope which is of interest here. 


If you just want to model the variance and you are able to reformulate your twolevel model as a single level multivariate model you can use the constraint feature, see example 5.23 in the user's guide. Another approach is to use mixtures with a level 2 class variable and allow the variance to take different values across class. The third approach (probably the best) is illustrated in this montecarlo example  however I did this for an observed variable rather than a factor for simplicity. You can see I used a constant of 0.1 to avoid singularity issues. This method gives you an actual variable on the between level that is not the variance but the square root of the variance. Run this example in Mplus to see the details. montecarlo: names are y; nobservations = 10000; nreps = 1; CSIZES = 500(20); ncsize = 1; ANALYSIS: TYPE = twolevel random; estimator=ml; algo=int; model population: %within% s  y on e; y@0.1; e@1; e by; %between% s*1; y*1; [y*1]; s with y*0.2; [s*2]; model: %within% s  y on e; y@0.1; e@1; e by; %between% s*1; y*1; [y*1]; s with y*0.2; [s*2]; 

Back to top 