统计建模与R软件

loading 分享 2026-11-7 下载文档

---

Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 19.93 on 14 degrees of freedom Multiple R-squared: 0.551, Adjusted R-squared: 0.4547 F-statistic: 5.726 on 3 and 14 DF, p-value: 0.009004 回归方程为 y=44.9290+1.8033x1-0.1337x2+0.1668x3 (2)

回归方程显著,但有些回归系数不显著。 (3)

> lm.step<-step(lm.sol) Start: AIC=111.2 y ~ x1 + x2 + x3

Df Sum of Sq RSS AIC - x2 1 36.0 5599.4 109.3 5563.4 111.2 - x3 1 849.8 6413.1 111.8 - x1 1 4617.8 10181.2 120.1

Step: AIC=109.32 y ~ x1 + x3

Df Sum of Sq RSS AIC 5599.4 109.3 - x3 1 833.2 6432.6 109.8 - x1 1 5169.5 10768.9 119.1

> summary(lm.step)

Call:

lm(formula = y ~ x1 + x3, data = pho)

Residuals:

Min 1Q Median 3Q Max

-29.713 -11.324 -2.953 11.286 48.679

Coefficients:

Estimate Std. Error t value Pr(>|t|)

(Intercept) 41.4794 13.8834 2.988 0.00920 ** x1 1.7374 0.4669 3.721 0.00205 ** x3 0.1548 0.1036 1.494 0.15592 ---

Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 19.32 on 15 degrees of freedom Multiple R-squared: 0.5481, Adjusted R-squared: 0.4878 F-statistic: 9.095 on 2 and 15 DF, p-value: 0.002589 x3仍不够显著。

再用drop1函数做逐步回归。 > drop1(lm.step) Single term deletions

Model:

y ~ x1 + x3

Df Sum of Sq RSS AIC 5599.4 109.3 x1 1 5169.5 10768.9 119.1 x3 1 833.2 6432.6 109.8 可以考虑再去掉x3.

> lm.opt<-lm(y~x1,data=pho);summary(lm.opt)

Call:

lm(formula = y ~ x1, data = pho)

Residuals:

Min 1Q Median 3Q Max

-31.486 -8.282 -1.674 5.623 59.337

Coefficients:

Estimate Std. Error t value Pr(>|t|)

(Intercept) 59.2590 7.4200 7.986 5.67e-07 *** x1 1.8434 0.4789 3.849 0.00142 ** ---

Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 20.05 on 16 degrees of freedom Multiple R-squared: 0.4808, Adjusted R-squared: 0.4484 F-statistic: 14.82 on 1 and 16 DF, p-value: 0.001417 皆显著。

Ex6.3

> x<-c(1,1,1,1,2,2,2,3,3,3,4,4,4,5,6,6,6,7,7,7,8,8,8,9,11,12,12,12) >

y<-c(0.6,1.6,0.5,1.2,2.0,1.3,2.5,2.2,2.4,1.2,3.5,4.1,5.1,5.7,3.4,9.7,8.6,4.0,5.5,10.5,17.5,13.4,4.5,30.4,12.4,13.4,26.2,7.4) > plot(x,y)

> lm.sol<-lm(y~1+x)

> summary(lm.sol)

Call:

lm(formula = y ~ 1 + x)

Residuals:

Min 1Q Median 3Q Max

-9.8413 -2.3369 -0.0214 1.0592 17.8320

Coefficients:

Estimate Std. Error t value Pr(>|t|) (Intercept) -1.4519 1.8353 -0.791 0.436 x 1.5578 0.2807 5.549 7.93e-06 *** ---

Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 5.168 on 26 degrees of freedom Multiple R-squared: 0.5422, Adjusted R-squared: 0.5246 F-statistic: 30.8 on 1 and 26 DF, p-value: 7.931e-06

线性回归方程为 y=-1.4519+1.5578x,通过F 检验。常数项参数未通过t 检验。 > abline(lm.sol)

> y.yes<-resid(lm.sol) > y.fit<-predict(lm.sol) > y.rst<-rstandard(lm.sol) > plot(y.yes~y.fit)


统计建模与R软件.doc 将本文的Word文档下载到电脑
搜索更多关于: 统计建模与R软件 的文档
相关推荐
相关阅读