Skip to content
Prev 200436 / 398503 Next

extracting estimated covariance parameters from lme fit

The VarCorr function will extract the components of the random effects
covariance matrix, but note the quirk that it returns values as
characters:

library(nlme)
f1 <- lme(distance ~ age, data = Orthodont, random = ~1 + age|Subject)
(vc <- VarCorr(f1))
# Subject = pdLogChol(1 + age)
#             Variance   StdDev    Corr
# (Intercept) 5.41508724 2.3270340 (Intr)
# age         0.05126955 0.2264278 -0.609
# Residual    1.71620401 1.3100397

str(vc)
#  'VarCorr.lme' chr [1:3, 1:3] "5.41508724" "0.05126955" "1.71620401" ...
# - attr(*, "dimnames")=List of 2
#   ..$ : chr [1:3] "(Intercept)" "age" "Residual"
#   ..$ : chr [1:3] "Variance" "StdDev" "Corr"
#  - attr(*, "title")= chr "Subject = pdLogChol(1 + age)"

(sigma2.age <- as.numeric(vc[2, 1]))
# [1] 0.05126955


hth,

Kingsford Jones

On Mon, Nov 16, 2009 at 9:25 AM, Green, Gerwyn (greeng6)
<g.green8 at lancaster.ac.uk> wrote: