I am learning mixed effect model from here.
I built a simplified model and trying to extract the $\gamma$ vector from linear mixed effect model
$$y=X\beta+Z\gamma+\epsilon$$
then calculate variance of $\gamma$. (It is a toy model and we only have random effect on intercept, so $\gamma$ is a vector not a matrix)
Why it is not equal to model summary
? (model summary shows DID intercept variance is $1.148$, but variance of $\gamma$ is $1.1026$). What I am missing here?
> library(lme4)
> dat <-read.csv("http://stats.idre.ucla.edu/stat/data/hdp.csv")
> dat=dat[1:100,c("Age","Sex", "DID","mobility")]
> m <- lmer(mobility ~ 1 + Age + Sex + (1 | DID), data = dat)
> summary(m)
Linear mixed model fit by REML ['lmerMod']
Formula: mobility ~ 1 + Age + Sex + (1 | DID)
Data: dat
REML criterion at convergence: 228.5
Scaled residuals:
Min 1Q Median 3Q Max
-3.3152 -0.4710 -0.0252 0.9330 1.7854
Random effects:
Groups Name Variance Std.Dev.
DID (Intercept) 1.1480 1.0714
Residual 0.4532 0.6732
Number of obs: 100, groups: DID, 5
Fixed effects:
Estimate Std. Error t value
(Intercept) 3.28826 0.76484 4.299
Age 0.01235 0.01178 1.048
Sexmale -0.09126 0.14836 -0.615
Correlation of Fixed Effects:
(Intr) Age
Age -0.766
Sexmale -0.097 0.030
> var(as.numeric(getME(m, "b")))
[1] 1.102682