ImportOption
我有兴趣从NLME拟合的摘要输出中提取信息。
我想提取
library(nlme)
fm1 <- nlme(height ~ SSasymp(age, Asym, R0, lrc),
data = Loblolly,
fixed = Asym + R0 + lrc ~ 1,
random = Asym ~ 1,
start = c(Asym = 103, R0 = -8.5, lrc = -3.3))
> summary(fm1)
Nonlinear mixed-effects model fit by maximum likelihood
Model: height ~ SSasymp(age, Asym, R0, lrc)
Data: Loblolly
AIC BIC logLik
239.4856 251.6397 -114.7428
Random effects:
Formula: Asym ~ 1 | Seed
Asym Residual
StdDev: 3.650642 0.7188625
Fixed effects: Asym + R0 + lrc ~ 1
Value Std.Error DF t-value p-value
Asym 101.44960 2.4616951 68 41.21128 0
R0 -8.62733 0.3179505 68 -27.13420 0
lrc -3.23375 0.0342702 68 -94.36052 0
Correlation:
Asym R0
R0 0.704
lrc -0.908 -0.827
Standardized Within-Group Residuals:
Min Q1 Med Q3 Max
-2.23601930 -0.62380854 0.05917466 0.65727206 1.95794425
Number of Observations: 84
Number of Groups: 14
但没有运气。fm1$apVar
提取fixef(fm1)
,但这些值与固定效果下的Std.Error列下的值完全匹配?sqrt(diag(fm1$varFix))
提取)fm1$logLik
提取)我的最终目标是适合多个模型,并将各自的摘要估算值存储到有条理的fm1$Residuals
中。
data.frame
假设我的列表对象看起来像fm1 <- nlme(height ~ SSasymp(age, Asym, R0, lrc),
data = Loblolly,
fixed = Asym + R0 + lrc ~ 1,
random = Asym ~ 1,
start = c(Asym = 103, R0 = -8.5, lrc = -3.3))
fm2 <- nlme(height ~ SSasymp(age, Asym, R0, lrc),
data = Loblolly,
fixed = Asym + R0 + lrc ~ 1,
random = Asym ~ 1,
start = c(Asym = 103, R0 = -5.4, lrc = -3.3))
summary(fm1)
summary(fm2)
mylist = list(NULL, summary(fm1), NULL, summary(fm2), NULL, NULL)
。现在我想创建一个看似如下的mylist
:
data.frame
要创建此data.frame(行数对应于model FixedAsym FixedAsymStdError FixedR0 ... Residual
1 101.44960 2.4616951 -8.62733 0.7188625
2 101.44934 2.4616788 -8.62736 ... 0.7188625
中我有多少个模型摘要),我需要系统地从模型摘要输出中提取这些值(编号为1-5)。
答案 0 :(得分:0)
这里还有一些......
as.numeric(VarCorr(fm1)[,2])
# [1] 3.6506418 0.7188625
summary(fm1)$tTable[,2]
# Asym R0 lrc
# 2.46169512 0.31795045 0.03427017
# looks like you don't need this one anymore, but here's a way of getting it
summary(fm1)$corFixed
# Asym R0 lrc
# Asym 1.0000000 0.7039498 -0.9077793
# R0 0.7039498 1.0000000 -0.8271022
# lrc -0.9077793 -0.8271022 1.0000000
道歉,这不是完整的答案 - 可能很难创建像您一样描述的汇总表,因为每个潜在行的结构将不同,并且将取决于哪些变量是包括作为固定和随机效应。