第一范文网 - 专业文章范例文档资料分享平台

统计建模与R软件

来源:用户分享 时间:2025/5/16 14:33:09 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

x 54.893 2.350 23.36 2.26e-11 *** ---

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

Residual standard error: 17.59 on 12 degrees of freedom Multiple R-squared: 0.9785, Adjusted R-squared: 0.9767 F-statistic: 545.5 on 1 and 12 DF, p-value: 2.265e-11 线性回归模型为y=523.800+54.893x,通过t检验和F检验。 (2)

> lm.sol<-lm(y~1+x+I(x^2));summary(lm.sol)

Call:

lm(formula = y ~ 1 + x + I(x^2))

Residuals:

Min 1Q Median 3Q Max

-10.6643 -5.6622 -0.4655 5.5000 10.6679

Coefficients:

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

(Intercept) 502.5560 4.8500 103.619 < 2e-16 *** x 80.3857 3.7861 21.232 2.81e-10 *** I(x^2) -4.2488 0.6063 -7.008 2.25e-05 *** ---

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

Residual standard error: 7.858 on 11 degrees of freedom Multiple R-squared: 0.9961, Adjusted R-squared: 0.9953 F-statistic: 1391 on 2 and 11 DF, p-value: 5.948e-14 多项式回归模型为:

y=502.5560+80.3857x-4.2488x^2,通过t检验和F检验。 (3)作散点图和拟合曲线:

> plot(x,y)

> xfit<-seq(0,6,0.01)

> yfit<-predict(lm.sol,data.frame(x=xfit)) > lines(xfit,yfit)

Ex6.8 读入数据:

> cancer<-read.table(\> cancer

x1 x2 x3 x4 x5 y 1 70 64 5 1 1 1 2 60 63 9 1 1 0 3 70 65 11 1 1 0 4 40 69 10 1 1 0 5 40 63 58 1 1 0 6 70 48 9 1 1 0 7 70 48 11 1 1 0 8 80 63 4 2 1 0 9 60 63 14 2 1 0 10 30 53 4 2 1 0 11 80 43 12 2 1 0 12 40 55 2 2 1 0 13 60 66 25 2 1 1 14 40 67 23 2 1 0 15 20 61 19 3 1 0

16 50 63 4 3 1 0 17 50 66 16 0 1 0 18 40 68 12 0 1 0 19 80 41 12 0 1 1 20 70 53 8 0 1 1 21 60 37 13 1 1 0 22 90 54 12 1 0 1 23 50 52 8 1 0 1 24 70 50 7 1 0 1 25 20 65 21 1 0 0 26 80 52 28 1 0 1 27 60 70 13 1 0 0 28 50 40 13 1 0 0 29 70 36 22 2 0 0 30 40 44 36 2 0 0 31 30 54 9 2 0 0 32 30 59 87 2 0 0 33 40 69 5 3 0 0 34 60 50 22 3 0 0 35 80 62 4 3 0 0 36 70 68 15 0 0 0 37 30 39 4 0 0 0 38 60 49 11 0 0 0 39 80 64 10 0 0 1 40 70 67 18 0 0 1 >

glm.sol<-glm(y~x1+x2+x3+x4+x5,family=binomial,data=cancer);summary(glm.sol)

Call:

glm(formula = y ~ x1 + x2 + x3 + x4 + x5, family = binomial, data = cancer)

Deviance Residuals:

Min 1Q Median 3Q Max

-1.71500 -0.66725 -0.22254 0.09936 2.23936

Coefficients:

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

(Intercept) -7.01140 4.47534 -1.567 0.1172 x1 0.09994 0.04304 2.322 0.0202 * x2 0.01415 0.04697 0.301 0.7631 x3 0.01749 0.05458 0.320 0.7486 x4 -1.08297 0.58721 -1.844 0.0651 .

x5 -0.61309 0.96066 -0.638 0.5233 ---

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

(Dispersion parameter for binomial family taken to be 1)

Null deviance: 44.987 on 39 degrees of freedom Residual deviance: 28.392 on 34 degrees of freedom AIC: 40.392

Number of Fisher Scoring iterations: 6 有的系数并不显著。 下面做逐步回归:

> glm.new<-step(glm.sol) Start: AIC=40.39

y ~ x1 + x2 + x3 + x4 + x5

Df Deviance AIC - x3 1 28.484 38.484 - x2 1 28.484 38.484 - x5 1 28.799 38.799 28.392 40.392 - x4 1 32.642 42.642 - x1 1 38.306 48.306

Step: AIC=38.48

y ~ x1 + x2 + x4 + x5

Df Deviance AIC - x2 1 28.564 36.564 - x5 1 28.993 36.993 28.484 38.484 - x4 1 32.705 40.705 - x1 1 38.478 46.478

Step: AIC=36.56 y ~ x1 + x4 + x5

Df Deviance AIC - x5 1 29.073 35.073 28.564 36.564 - x4 1 32.892 38.892 - x1 1 38.478 44.478

搜索更多关于: 统计建模与R软件 的文档
统计建模与R软件.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c1dcuj6idyr553972zwpb_10.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top