这是在一种打印方法中计算的(我怀疑print.summary.pdMat
)。最简单的方法是捕获输出。
library(nlme)
fit <- lme(distance ~ Sex, data = Orthodont, random = ~ age|Subject)
summary(fit)
# Linear mixed-effects model fit by REML
# Data: Orthodont
# AIC BIC logLik
# 483.1635 499.1442 -235.5818
#
# Random effects:
# Formula: ~age | Subject
# Structure: General positive-definite, Log-Cholesky parametrization
# StdDev Corr
# (Intercept) 7.3913363 (Intr)
# age 0.6942889 -0.97
# Residual 1.3100396
# <snip/>
ttt <- capture.output(print(summary(fit$modelStruct), sigma = fit$sigma))
as.numeric(unlist(strsplit(ttt[[6]],"\\s+"))[[2]])
#[1] 0.6942889
这是计算它的方法:
fit$sigma * attr(corMatrix(fit$modelStruct[[1]])[[1]],"stdDev")
#(Intercept) age
# 7.3913363 0.6942889