【发布时间】:2015-10-12 18:14:12
【问题描述】:
我正在对查询文件中的不同列执行多重回归。我的任务是从 R 中的回归函数 lm 中提取某些结果。
目前为止,
> reg <- lm(query$y1 ~ query$x1 + query$x2)
> summary(reg)
Call:
lm(formula = query$y1 ~ query$x1 + query$x2)
Residuals:
1 2 3 4
7.68 -4.48 -7.04 3.84
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 1287.26 685.75 1.877 0.312
query$x1 -29.30 20.92 -1.400 0.395
query$x2 -116.90 45.79 -2.553 0.238
Residual standard error: 11.97 on 1 degrees of freedom
Multiple R-squared: 0.9233, Adjusted R-squared: 0.7699
F-statistic: 6.019 on 2 and 1 DF, p-value: 0.277
要提取系数、r 平方和 F 统计量,我使用以下方法:
reg$coefficients
summary(reg)$r.squared
summary(reg)$fstatistic
我还想提取 p 值 0.277。
是否有一段代码可以做到这一点?
谢谢
【问题讨论】:
标签: r linear-regression p-value