(完整word版)R软件一元线性回归分析.pdf
《(完整word版)R软件一元线性回归分析.pdf》由会员分享,可在线阅读,更多相关《(完整word版)R软件一元线性回归分析.pdf(8页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、R 软件一元线性回归分析数据选自数理统计教材例题8.4.1 合金钢强度与碳含量的数据序号碳含量/%合金钢强度/107pa 1 0.10 42.0 2 0.11 43.0 3 0.12 45.0 4 0.13 45.0 5 0.14 45.0 6 0.15 47.5 7 0.16 49.0 8 0.17 53.0 9 0.18 50.0 10 0.20 55.0 11 0.21 55.0 12 0.23 60.0 这里取碳含量为 x 是普通变量,取合金钢强度为y 是随机变量使用 R软件对以上数据绘出散点图程序如下:x=matrix(c(0.1,42,0.11,43,0.12,45,0.13,45
2、,0.14,45,0.15,47.5,0.16,49,0.17,53,0.18,50,0.2,55,0.21,55,0.23,60),nrow=12,ncol=2,byrow=T,dimnames=list(1:12,c(C,E)outputcost=as.data.frame(x)plot(outputcost$C,outputcost$E)精品资料-欢迎下载-欢迎下载 名师归纳-第 1 页,共 8 页 -0.100.120.140.160.180.200.2245505560outputcost$Coutputcost$E很显然这些点基本上(但并不精确地)落在一条直线上。下面在之前数据录入
3、的基础上做回归分析(程序接前文,下同)lm.sol=lm(EC,data=outputcost)summary(lm.sol)得到以下结果:Call:lm(formula=E C,data=outputcost)Residuals:Min 1Q Median 3Q Max-2.00449-0.63600-0.02401 0.71297 2.32451 Coefficients:Estimate Std.Error t value Pr(|t|)(Intercept)28.083 1.567 17.92 6.27e-09*C 132.899 9.606 13.84 7.59e-08*-Signi
4、f.codes:0*0.001*0.01 *0.05 .0.1 1 Residual standard error:1.309 on 10 degrees of freedom Multiple R-squared:0.9503,Adjusted R-squared:0.9454 F-statistic:191.4 on 1 and 10 DF,p-value:7.585e-08 由计算结果分析:精品资料-欢迎下载-欢迎下载 名师归纳-第 2 页,共 8 页 -文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K
5、6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6
6、ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G
7、3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文
8、档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB
9、10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9
10、T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 H
11、I8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8常数项0=28.083,变量(即碳含量)的系数1=132.899 得到回归方程:y=28.083+132.899x 由于回归模型建立使用的是最小二乘法,而最小二乘法只是一种单纯的数学方法 ,存在着一定的缺陷,即不论变量间有无相关关系或有无显著线性相关关系,用最小二乘法都可以找到一条直线去拟合变量间关系
12、。所以回归模型建立之后,还要对其进行显著性检验:在上面的结果中sd(0)=1.567,sd(1)=9.606。而对应于两个系数的 P值 6.27e-09和 7.59e-08,故是非常显著的。关于方程的检验,残差的标准差=1.309。相关系数的平方 R2=0.9503。关于 F分布的 P值为 7.585e-08,也是非常显著的。我们将得到的直线方程画在散点图上,程序如下:abline(lm.sol)得到散点图及相应的回归直线:精品资料-欢迎下载-欢迎下载 名师归纳-第 3 页,共 8 页 -文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8
13、E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9
14、 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P1
15、0K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R
16、6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G
17、6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A
18、8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:
19、CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A80.100.120.140.160.180.200.2245505560outputcost$Coutputcost$E下面分析残差:在 R软件中,可用函数residuals()计算回归方程的残差。程序如下:y.res=residuals(lm.sol);plot(y.re
20、s)得到残差图精品资料-欢迎下载-欢迎下载 名师归纳-第 4 页,共 8 页 -文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB1
21、0G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T
22、1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI
23、8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6
24、C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 Z
25、V2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3Y7A8文档编码:CB10G8E9T1I9 HI8P10K6C4R6 ZV2G6G3
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 完整 word 软件 一元 线性 回归 分析
限制150内