|
> as.data.frame(summary(reg.full))
Error in as.data.frame.default(summary(reg.full)) :
cannot coerce class "summary.lm" into a data.frame
要是导入到excel的话只能一个一个的输入大data frame里边去了。
> summary
Call:
lm(formula = y ~ x1 + x2 + x3 + x4)
Residuals:
Min 1Q Median 3Q Max
-25.3219 -6.9330 -0.1639 6.9856 24.5862
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 87.09391 16.76139 5.196 1.16e-06 ***
x1 0.06368 0.09884 0.644 0.521
x2 0.08850 0.20093 0.440 0.661
x3 0.04784 0.13474 0.355 0.723
x4 0.19736 0.95421 0.207 0.837
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 10.22 on 95 degrees of freedom
Multiple R-squared: 0.007915, Adjusted R-squared: -0.03386
F-statistic: 0.1895 on 4 and 95 DF, p-value: 0.9434
> summary$coef
Estimate Std. Error t value Pr(>|t|)
(Intercept) 87.09390823 16.76139373 5.1961018 1.160785e-06
x1 0.06367712 0.09884187 0.6442322 5.209773e-01
x2 0.08850245 0.20093214 0.4404594 6.606050e-01
x3 0.04783535 0.13473790 0.3550252 7.233577e-01
x4 0.19735533 0.95421041 0.2068258 8.365886e-01
> summary$r.sq
[1] 0.00791506
> summary$adj.r.sq
[1] -0.03385694
> summary$fsta
value numdf dendf
0.1894824 4.0000000 95.0000000
> 1-pf(summary$fsta[1],summary$fsta[2],summary$fsta[3]) ###calculating P-value manually
value
0.9433616
> summary$sigma
[1] 10.22026
然后一个一个写入到data frame里边去。不过这办法实在是有些笨。希望大家能找到一个比较快捷一点的方法分享一下。
另外要控制小数点的话用digits,不过不见得都管用,有些数字实在太小了!
|