This is not that difficult; the VarCorr
accessor method is designed precisely to recover this information. It's a little bit harder than it should be since the VarCorr
method returns the variance-covariance as a character matrix rather than as numeric (I use storage.mode
to convert to numeric without losing the structure, and suppressWarnings
to ignore the warnings about NAs)
library(nlme)
fit <- lme(distance ~ Sex, data = Orthodont, random = ~ age|Subject)
vc <- VarCorr(fit)
suppressWarnings(storage.mode(vc) <- "numeric")
vc[1:2,"StdDev"]
## (Intercept) age
## 7.3913363 0.6942889
In your case, you would use vc["t","StdDev"]
.