为什麽是summary(总结)?lm)“summaryDefault”“table”

vltsax25  于 2023-05-04  发布在  其他
关注(0)|答案(1)|浏览(170)

我有一个线性模型:linearMod <- lm(dist ~ speed, data=cars) summary(linearMod)全部正常,并且:

summary(summary(linearMod))
              Length Class  Mode   
call           3     -none- call   
terms          3     terms  call   
residuals     50     -none- numeric
coefficients   8     -none- numeric
aliased        2     -none- logical
sigma          1     -none- numeric
df             3     -none- numeric
r.squared      1     -none- numeric
adj.r.squared  1     -none- numeric
fstatistic     3     -none- numeric
cov.unscaled   4     -none- numeric

但是

class(summary(summary(linearMod)))
[1] "summaryDefault" "table"

请问我如何访问fstatistic,这是我想要的
我希望能用

sr <- summary(summary(linearMod))
    sr$fstatistic

但我明白

summary(summary(linearMod))$fstatistic
Error in summary(summary(linearMod))$fstatistic : 
  $ operator is invalid for atomic vectors
disho6za

disho6za1#

我想你只是想要summary(linearMod)$fstatistic。在summary(linearMod)周围放置另一个summary()会生成一个类似列表的对象,它是摘要的摘要!

> linearMod <- lm(mpg~ hp, mtcars)
> class(linearMod)
[1] "lm"
> class(summary(linearMod))
[1] "summary.lm"
> class(summary(summary(linearMod)))
[1] "summaryDefault" "table"

相关问题