1
$\begingroup$

Consider this simple simulated dataset (all groups are normally distributed with sd=1) made up by 4 level 1 groups (lv1) and 2 level 2 groups. The mean of the 4 distribution is 5, 15, 5 and 15 respectively. dataset 1 Here is the lmer output:

Linear mixed model fit by maximum likelihood  ['lmerMod']
Formula: y ~ 1 + (1 | lv2/lv1)
   Data: df

     AIC      BIC   logLik deviance df.resid 
 11499.1  11524.2  -5745.5  11491.1     3996 

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-3.5256 -0.6561 -0.0039  0.6748  3.8039 

Random effects:
 Groups   Name        Variance  Std.Dev.
 lv1:lv2  (Intercept) 2.502e+01 5.002330
 lv2      (Intercept) 1.679e-05 0.004098
 Residual             1.025e+00 1.012470
Number of obs: 4000, groups:  lv1:lv2, 4; lv2, 2

Fixed effects:
            Estimate Std. Error t value
(Intercept)   10.004      2.501       4

As you can see the variance of lv1 groups is approximately 25, If I understand correctly It is calculated as the variance (biased) of points around the mean of each level 2 group. In formula: $$ \sigma_1 \approx \frac{(5-10)^2 + (15-10)^2 + (5-10)^2 + (15-10)^2}{4} = 25 $$ And the variance in level 2 groups is the variance around the 'overall mean' of the level 2 groups, thus is 0.

Now consider this second dataset. It's the same as before but the level 2 group g2 has been shifted up by 20 units dataset 2
The means for the 4 groups are {5,15,25,35} respectively. This is the lmer output:

Linear mixed model fit by maximum likelihood  ['lmerMod']
Formula: y ~ 1 + (1 | lv2/lv1)
   Data: df2

     AIC      BIC   logLik deviance df.resid 
 11428.9  11454.1  -5710.5  11420.9     3996 

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-3.6374 -0.6673  0.0046  0.6538  3.7098 

Random effects:
 Groups   Name        Variance Std.Dev.
 lv1:lv2  (Intercept) 50.015   7.072   
 lv2      (Intercept) 74.495   8.631   
 Residual              1.006   1.003   
Number of obs: 4000, groups:  lv1:lv2, 4; lv2, 2

Fixed effects:
            Estimate Std. Error t value
(Intercept)   19.999      7.053   2.835

I would expect that the variance for lv1 groups to be:

$$ \sigma_1 = \frac{(5-10)^2 + (15-10)^2 + (25-30)^2 + (35-30)^2}{4} = 25 $$

But in lmer() is actually calculated differently, and is twice as much.
Do someone knows why or how this variance is calculated?

$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.