Reputation: 1281
I'm trying to extract this section of the model summary from a set of glmms. I want both the variance and the standard deviation.
Random effects:
Groups Name Variance Std.Dev.
herd (Intercept) 0.4123 0.6421
Number of obs: 56, groups: herd, 15
I tried following this answer Extract random effect variances from lme4 mer model object
But I can't seem to get the variance, only the standard deviation. I thought perhaps this was because I was using glmer instead of lmer, but I seem to get the same results.
gm1 <- lmer( size ~ period + (1 | herd), data = cbpp)
summary(gm1)
Random effects:
Groups Name Variance Std.Dev.
herd (Intercept) 44.40 6.664
Residual 14.51 3.810
Number of obs: 56, groups: herd, 15
> VarCorr(gm1, comp="Variance")
Groups Name Std.Dev.
herd (Intercept) 6.6636
Residual 3.8096
> VarCorr(gm1, comp="Std.Dev.")
Groups Name Std.Dev.
herd (Intercept) 6.6636
Residual 3.8096
> VarCorr(gm1, comp=c("Variance","Std.Dev."))
Groups Name Std.Dev.
herd (Intercept) 6.6636
Residual 3.8096
gm2 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
data = cbpp, family = binomial)
summary(gm2)
Random effects:
Groups Name Variance Std.Dev.
herd (Intercept) 0.4123 0.6421
Number of obs: 56, groups: herd, 15
> VarCorr(gm2, comp="Variance")
Groups Name Std.Dev.
herd (Intercept) 0.64207
> VarCorr(gm2, comp="Std.Dev.")
Groups Name Std.Dev.
herd (Intercept) 0.64207
> VarCorr(gm2, comp=c("Variance","Std.Dev."))
Groups Name Std.Dev.
herd (Intercept) 0.64207
Any ideas what might be going on here?
Upvotes: 2
Views: 509
Reputation: 226087
comp
is an argument to the print()
method, not to VarCorr
.
print(VarCorr(gm1), comp=c("Variance", "Std.Dev."))
Groups Name Variance Std.Dev.
herd (Intercept) 44.404 6.6636
Residual 14.513 3.8096
You might also be interested in
as.data.frame(VarCorr(gm1))[,c("vcov", "sdcor")]
vcov sdcor
1 44.40371 6.663611
2 14.51309 3.809605
Upvotes: 2