[R-sig-ME] How to extract variance components in lme4 1.0 ?

Ben Bolker bbolker at gmail.com
Thu Sep 12 23:42:42 CEST 2013


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



More information about the R-sig-mixed-models mailing list