An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-mixed-models/attachments/20130912/7b4a1e1e/attachment.pl>
How to extract variance components in lme4 1.0 ?
3 messages · Kevin Wright, Ben Bolker
Kevin Wright <kw.stat at ...> writes:
Note, I don't want to print() them. I want to use them in calculations
(e.g. change from variances to proportions of variation explained).
VarCorr() can be used to print them, but as yet I haven't been able to find
out how to easily extract the variances.
data(Orthodont, package="nlme")
fm1 <- lmer(distance ~ age + (age|Subject), data = Orthodont)
VarCorr(fm1)
Groups Name Std.Dev. Corr
Subject (Intercept) 2.32704
age 0.22643 -0.609
Residual 1.31004
This is possible but undocumented (I've just documented it
in the master branch [1.1-0]):
print(VarCorr(fm1),comp=c("Std.Dev.","Variance"))
Kevin Wright <kw.stat at ...> writes:
Note, I don't want to print() them. I want to use them in calculations
(e.g. change from variances to proportions of variation explained).
VarCorr() can be used to print them, but as yet I haven't been able to find
out how to easily extract the variances.
data(Orthodont, package="nlme")
fm1 <- lmer(distance ~ age + (age|Subject), data = Orthodont)
VarCorr(fm1)
Groups Name Std.Dev. Corr
Subject (Intercept) 2.32704
age 0.22643 -0.609
Residual 1.31004
Oops, I didn't read carefully enough.
If you're willing to have the variances without the correlations/
covariances included,
unlist(lapply(VarCorr(fm1),diag))
Subject.(Intercept) Subject.age
5.41511574 0.05126949