Skip to content
Prev 1212 / 20628 Next

extracting random effect standard deviation

On Fri, Aug 1, 2008 at 1:38 PM, Daniel Ezra Johnson
<danielezrajohnson at gmail.com> wrote:
Use the VarCorr extractor function.  This returns a list of
variance-covariance matrices so you want something like

stddevs <- function(obj)
    unlist(lapply(VarCorr(obj), function(m) sqrt(diag(m))))

I'll leave it as an exercise to the reader to decide what names should
be given to these elements and to get them in the right places.
Doing that correctly in the general case is non-trivial.

I have been playing with the idea of having an optional argument
"type" for the VarCorr extractor so that the user can specify the raw
form (the factors of the relative variance-covariance matrices as
stored internally) or the variance-covariance form or the standard
deviations and correlations form or a transformed version as the
logarithm of the standard deviations and Fisher's z-transformation
(the hyperbolic arc-tangent) of the correlations.  At different times
you want these estimates in different forms.