Skip to content

Extracting SD of random effects from lme object

4 messages · Kingsford Jones, Ben Domingue, Douglas Bates

#
Hello,
How do I get the standard deviations for the random effects out of the
lme object?  I feel like there's probably a simple way of doing this,
but I can't see it.  Using the first example from the documentation:
Linear mixed-effects model fit by REML
  Data: Orthodont
  Log-restricted-likelihood: -221.3183
  Fixed: distance ~ age
(Intercept)         age
 16.7611111   0.6601852

Random effects:
 Formula: ~age | Subject
 Structure: General positive-definite
            StdDev    Corr
(Intercept) 2.3270339 (Intr)
age         0.2264276 -0.609
Residual    1.3100399

Number of Observations: 108
Number of Groups: 27

I want to extract the column vector (2.3270339, 0.2264276,
1.3100399)'.  Any thoughts?
Thanks,
Ben
#
On Mon, Mar 23, 2009 at 11:26 AM, Ben Domingue <ben.domingue at gmail.com> wrote:
To get the covariance matrix of the random effects:
Random effects variance covariance matrix
            (Intercept)       age
(Intercept)     5.41510 -0.321060
age            -0.32106  0.051269
  Standard Deviations: 2.327 0.22643


One way to extract the standard deviations shown by the print method above is:
(Intercept)         age
  2.3270339   0.2264276
Warning message:
In sqrt(getVarCov(fm1)) : NaNs produced


And to get the estimate of the error standard deviation:
[1] 1.31004


hth,

Kingsford Jones
#
On Mon, Mar 23, 2009 at 1:18 PM, Kingsford Jones
<kingsfordjones at gmail.com> wrote:
That's what I needed.  Thanks.


Ben
#
On Mon, Mar 23, 2009 at 2:18 PM, Kingsford Jones
<kingsfordjones at gmail.com> wrote:
You can avoid the warning message if you extract the diagonal first
then take the square root.

sqrt(diag(getVarCov(fm1)))