资源描述:
《用r软件进行一元线性回归实验报告》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、数理统计上机报告上机实验题目:用R软件进行一元线性回归上机实验目的:1、进一步理解假设实验的基本思想,学会使用实验检验和进行统计推断。2、学会利用R软件进行假设实验的方法。一元线性回归基本理论、方法:基本理论:假设预测目标因变量为Y,影响它变化的一个自变量为X,因变量随自变量的增(减)方向的变化。一元线性回归分析就是要依据一定数量的观察样本(Xi,Yi),i=1,2…,n,找出回归直线方程Y=a+b*X 方法:对应于每一个Xi,根据回归直线方程可以计算出一个因变量估计值Yi。回归方程估计值Yi与实际观察值Yj之间的误差记作e-i=
2、Yi-Yi。显然,n个误差的总和越小,说明回归拟合的直线越能反映两变量间的平均变化线性关系。据此,回归分析要使拟合所得直线的平均平方离差达到最小,据此,回归分析要使拟合所得直线的平均平方离差达到最小,简称最小二乘法将求出的a和b代入式(1)就得到回归直线Yi=a+bXi。那么,只要给定Xi值,就可以用作因变量Yi的预测值。(一)实验实例和数据资料:有甲、乙两个实验员,对同一实验的同一指标进行测定,两人测定的结果如下:实验号12345678甲4.33.23.83.53.54.83.33.9乙3.74.13.83.84.63.92.84
3、.4试问:甲、乙两人的测定有无显著差异?取显著水平α=0.05.上机实验步骤:6(1)设置假设:H0:u1-u-2=0:H1:u1-u-2<0(2)确定自由度为n1+n2-2=14;显著性水平a=0.05(3)计算样本均值样本标准差和合并方差统计量的观测值alpha<-0.05;n1<-8;n2<-8;x<-c(4.3,3.2,3.8,3.5,3.5,4.8,3.3,3.9);y<-c(3.7,4.1,3.8,3.8,4.6,3.9,2.8,4.4);var1<-var(x);xbar<-mean(x);var2<-var(y);y
4、bar<-mean(y);Sw2<-((n1-1)*var1+(n2-1)*var2)/(n1+n2-2)t<-(xbar-ybar)/(sqrt(Sw2)*sqrt(1/n1+1/n2));tvalue<-qt(alpha,n1+n2-2);(4)计算临界值:tvalue<-qt(alpha,n1+n2-2)(5)比较临界值和统计量的观测值,并作出统计推断实例计算结果及分析:alpha<-0.05;>n1<-8;>n2<-8;>x<-c(4.3,3.2,3.8,3.5,3.5,4.8,3.3,3.9);>y<-c(3.7,4.1,
5、3.8,3.8,4.6,3.9,2.8,4.4);>var1<-var(x);>xbar<-mean(x);>var2<-var(y);>ybar<-mean(y);>Sw2<-((n1-1)*var1+(n2-1)*var2)/(n1+n2-2)>t<-(xbar-ybar)/(sqrt(Sw2)*sqrt(1/n1+1/n2));>var1[1]0.2926786>xbar[1]3.7875>var2[1]0.29267866>ybar[1]3.8875Sw2[1]0.2926786>t[1]-0.3696873tvalue[1
6、]-1.76131分析:t=-0.3696873>tvalue=-1.76131,所以接受假设H1即甲乙两人的测定无显著性差异。(二)实验实例和数据资料:2.某型号玻璃纸的横向延伸率要求不低于65%,且其服从正态分布,现对一批该批号的玻璃纸测得100个数据如下:(x%横向延伸率)35.537.539.541.543.545.547.549.551.553.555.557.559.561.563.5频数7811991217145320201上机实验步骤:(1)设置假设:H0:u=65,H1:u<65.(2)确定自由度为n=100-1=
7、99;显著性水平a=0.05(3)6输入数据x<-c(35.5,35.5,35.5,35.5,35.5,35.5,35.5,37.5,37.5,37.5,37.5,37.5,37.5,37.5,37.5,39.5,39.5,39.5,39.5,39.5,39.5,39.5,39.5,39.5,39.5,39.5,41.5,41.5,41.5,41.5,41.5,41.5,41.5,41.5,41.5,43.5,43.5,43.5,43.5,43.5,43.5,43.5,43.5,43.5,45.5,45.5,45.5,45.5,45
8、.5,45.5,45.5,45.5,45.5,45.5,45.5,45.5,47.5,47.5,47.5,47.5,47.5,47.5,47.5,47.5,47.5,47.5,47.5,47.5,47.5,47.5,47.5,47.5