【问题标题】:why do I get different summary results for lmList vs lmList[[x]]为什么我会得到不同的 lmList 与 lmList[[x]] 的汇总结果
【发布时间】:2025-12-05 22:40:01
【问题描述】:

我使用 nlme 包中的 lmList 来运行基于不同组的各种回归 by 函数。鉴于我对summary.lmList 看到的解释,我对汇总结果感到有些困惑

The `summary.lm` method is applied to each lm component of object to produce
summary information on the individual fits, which is organized into a list of
summary statistics. 

The returned object is suitable for printing with the print.summary.lmList
method.

我的意思是下面

set.seed(123)
t <- data.frame(
        name=sample(c("a","b","c"),size=500,replace=T),
        x=1:500,
        y=1:500+rnorm(100)
      )
ta <- t[t$name=="a",]
lma <- lm(y~x,ta)
lmL <- lmList(y~x | name,t)
r1 <- summary(lmL)  
r2 <- summary(lmL[["a"]])  
r3 <- summary(lma)

谁能解释一下为什么 r1 中“a”显示的值与 r2 和 r3 中的值不匹配,而 r2 中的值与 r3 中的值匹配?

【问题讨论】:

    标签: r regression


    【解决方案1】:

    lmList的版本及其在nlme中的汇总方法有一个参数pool

    一个可选的逻辑值,指示是否对 残留标准误差应用于标准计算 摘要的偏差或标准误差。

    我猜如果您在调用 summary 时将其设置为 FALSE,您将获得相同的值。

    【讨论】:

      最近更新 更多