从摘要中获取变量?

时间:2013-12-06 00:58:48

标签: r linear-regression summary

当我对线性回归模型进行汇总时,我想抓住标准误差列。输出如下:

         Estimate Std. Error z value Pr(>|z|)    
(Intercept) -8.436954   0.616937 -13.676  < 2e-16 ***
x1          -0.138902   0.024247  -5.729 1.01e-08 ***
x2           0.005978   0.009142   0.654  0.51316    `
...

我只想要Std。错误列值存储在向量中。我该怎么做呢?我尝试了模型$ coefficients [,2],但这不断给我额外的价值。如果有人能提供帮助那就太棒了。

1 个答案:

答案 0 :(得分:1)

fit是线性模型,然后summary(fit)$coefficients[,2]有标准错误。输入?summary.lm

fit <- lm(y~x, myData)
summary(fit)$coefficients[,1]   # the coefficients
summary(fit)$coefficients[,2]   # the std. error in the coefficients
summary(fit)$coefficients[,3]   # the t-values
summary(fit)$coefficients[,4]   # the p-values