[R-sig-ME] extracting values from lmer

Ben Bolker bbolker at gmail.com
Fri Jan 6 00:01:22 CET 2012


espesser <robert.espesser at ...> writes:

> 
>   Hi Kevin,
> Maybe there is a better way (a function) , but you can use:
> 
> yourmodel <at> deviance["sigmaREML"]
> 
> it returns the residual std. dev.   :  0.13636
> (in case of the default setting for lmer()  , i.e. REML=TRUE)
> More generally,  " str(yourmodel)   "   gives useful informations  .
> R
> 
> Le 04/01/2012 12:56, Kevin Spring a écrit :
> > I am trying to extract the residual variance from the lmer function in the
> > package lme4.
> >
> > For example, I have the following response from lmer:
> >
> > Random effects:
> >>   Groups                  Name            Variance    Std.Dev.
> >>   Cell.line:DNA.extract (Intercept)  0.130554    0.36132
> >>   Residual                                    *0.018595*     0.13636
> >
> > I want to extract 0.018595 from this output.
> >
> > VarCorr allows me to extract the variance 0.130554, but I want to be able
> > to extract the Residual variance and I don't see a function that does this
> > in lme4.  Any ideas?


   You shouldn't have to work this hard to get it, but I would
suggest:

library(lme4)
example(lmer)  ## to get some examples to work with

attr(VarCorr(fm1),"sc")
[1] 25.59182

fm1 at deviance["sigmaREML"]
sigmaREML 
 25.59182 

both of these count a bit as digging into the internals
(which you're not supposed to do if you can help it, but
in this case you don't have a choice), but the former
is digging slightly less deep.

  Ben Bolker




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