R软件计算题-统计学专业课件.ppt
《R软件计算题-统计学专业课件.ppt》由会员分享,可在线阅读,更多相关《R软件计算题-统计学专业课件.ppt(25页珍藏版)》请在三一办公上搜索。
1、例,4.15 P179,(一个正态总体的区间估计),为估计一件物体的重量,a,,将其称了,10,次,得到的重量(单位:,kg,),为,10.1,10,9.8,10.5,9.7,10.1,9.9,10.2,10.3,9.9,,假设所称出物体重,量服从正态分布,求该物体重量,a,的置信系数为,0.95,的置信区间。,?,x-c(10.1,10,9.8,10.5,9.7,10.1,9.9,10.2,10.3,9.9),?,t.test(x),?,程序结果:,?,One Sample t-test,?,data:x,?,t=131.59,df=9,p-value=4.296e-16,?,alterna
2、tive hypothesis:true mean is not equal to 0,?,95 percent confidence interval:,?,9.877225 10.222775,?,sample estimates:,?,mean of x,?,10.05,得到的区间估计为:,9.88,10.22,?,例,4.18 P185(,均值差的区间估计),现从生产线上随机抽取样本,x1,x2,,,,,x12,和,y1,y2,,,,,y17,,都服,从正态分布,其均值分别为,u1=201.1,u2=499.7,,标准差分别为,2.4,4.7,。,给定置信系数,0.95,,试求,u1-
3、u2,的区间估计。,?,x-rnorm(12,501.1,2.4),?,y-rnorm(17,499.7,4.7),?,两样本方差不同,t.test(x,y),?,程序结果:,Welch Two Sample t-test,?,data:x and y,?,t=-0.6471,df=25.304,p-value=0.5234,?,alternative hypothesis:true difference in means is not equal to 0,?,95 percent confidence interval:,?,-3.657121 1.907620,?,sample esti
4、mates:,?,mean of x mean of y,?,500.7888 501.6635,?,u1-u2,的置信系数为,0.95,的区间估计为,-3.66,1.91,?,方差相同,t.test(x,y,var.equal=TRUE),例,4.19 P186(,配对数据情形下均值差的区间估计),抽查患者,10,名。记录下治疗前后血红蛋白的含量数据。试,求治疗前后变化的区间估计。,(,a=0.05,)。,?,x-c(11.3,15.0,15.0,13.5,12.8,10.0,11.0,12.0,13.0,12.3),?,y-c(14.0,13.8,14.0,13.5,13.5,12.0,1
5、4.7,11.4,13.8,12.0),?,t.test(x-y),?,程序结果:,?,One Sample t-test,?,data:x-y,?,t=-1.3066,df=9,p-value=0.2237,?,alternative hypothesis:true mean is not equal to 0,?,95 percent confidence interval:,?,-1.8572881 0.4972881,?,sample estimates:,?,mean of x,?,-0.68,?,治疗前后变化的区间估计为,-1.86,0.497,例,4.22 P193,(一个总体求
6、均值的单侧置信区间估计),从一批灯泡中随机地取,5,只作寿命试验测得寿命以小时计为,1050 1100 1120 1250 1280,设灯泡的寿命服从正态分布,.,求,灯泡寿命平均值的置信度为,0.95,的单侧置信下限,?,x-c(1050,1100,1120,1250,1280),?,t.test(x,alternative=greater),?,程序结果:,One Sample t-test,?,data:x,?,t=26.003,df=4,p-value=6.497e-06,?,alternative hypothesis:true mean is greater than 0,?,95
7、 percent confidence interval:,?,1064.9 Inf,?,sample estimates:,?,mean of x,?,1160,?,95%,的灯泡寿命在,1064.9,小时以上,习题,4.6 P201,甲、乙两种稻种分布播种在,10,块试验田中,每块试验田甲、乙稻种各种一半,,假设两稻种产量,X,Y,均服从正态分布,且方差相等,收获后,10,块试验田的产量,如下所示(单位:千克)。求出两稻种产量的期望差,u1-u2,的置信区间,(,a=0.05).,?,x-c(140,137,136,140,145,148,140,135,144,141),?,y-c(13
8、5,118,115,140,128,131,130,115,131,125),?,t.test(x,y,var.equal=T),?,程序结果,?,Two Sample t-test,?,data:x and y,?,t=4.6287,df=18,p-value=0.0002087,?,alternative hypothesis:true difference in means is not equal to 0,?,95 percent confidence interval:,?,7.536261 20.063739,?,sample estimates:,?,mean of x mea
9、n of y,?,140.6 126.8,?,置信区间为,7.536261,20.063739,习题,4.7,甲、乙两组生产同种导线,现从甲组生产的导线中随机抽取,4,根,从乙,组生产的导线中随机抽取,5,根,它们的电阻值分别为:甲:,0.143,0.142,0.143,0.137,;,乙:,0.140,0.142,0.136,0.138,0.140,;假设两组电阻值分别服从正态分,布,方差相同但未知,试求,u1-u2,的置信系数为,0.95,的区间估计。,?,x-c(0.143,0.142,0.143,0.137),?,y-c(0.140,0.142,0.136,0.138,0.140),?
10、,a-rnorm(4,mean(x),var(x),?,b-rnorm(5,mean(y),var(y),?,t.test(a,b),?,程序结果:,Welch Two Sample t-test,?,data:a and b,?,t=636.28,df=5.788,p-value=3.028e-15,?,alternative hypothesis:true difference in means is not equal to 0,?,95 percent confidence interval:,?,0.002041440 0.002057343,?,sample estimates:,
11、?,mean of x mean of y,?,0.1412494 0.1392000,?,区间为:,0.00204,0.00205,例,5.2 P209,(单个正态总体均值的假设检验),某种元件的寿命,X,(小时),服从正态分布,其中,f,方差和均值均未知,,16,只,元件的寿命如下:问是否有理由认为元件的平均寿命大于,255,小时。,?,x-,c(159,280,101,212,224,379,179,264,222,362,168,250,149,260,485,170),?,t.test(x,alternative=greater,mu=225),?,程序结果:,One Sample
12、t-test,?,data:x,?,t=0.66852,df=15,p-value=0.257,?,alternative hypothesis:true mean is greater than 225,?,95 percent confidence interval:,?,198.2321 Inf,?,sample estimates:,?,mean of x,例,5.6 P221,(二项分布总体的假设检验),有一批蔬菜种子的平均发芽率为,P=0.85,现在随机抽取,500,粒,用种衣剂进行浸,种处理,结果有,445,粒发芽,问种衣剂有无效果。,?,binom.test(445,500,p
13、=0.85),?,程序结果:,Exact binomial test,?,data:445 and 500,?,number of successes=445,number of trials=500,p-value=,0.01207,?,alternative hypothesis:true probability of success is not equal to,0.85,?,95 percent confidence interval:,?,0.8592342 0.9160509,?,sample estimates:,?,probability of success,?,0.89,
14、?,P,值,=0.012070.05,,拒绝原假设,认为种衣剂对种子发芽率有显著,效果。,习题,5.1 P249,正常男子血小板计数均值为,225*109/L,今测得,20,名男性油漆作业工,人的血小板计数值如下。问油漆工人的血小板计数与正常成年男子,有无差异?,?,x-,c(220,188,162,230,145,160,237,188,247,113,126,245,164,231,250,18,3,190,158,224,175),?,t.test(x,alternative=wo.side,mu=225),?,程序结果:,One Sample t-test,?,data:x,?,t=-
15、3.5588,df=19,p-value=0.002096,?,alternative hypothesis:true mean is not equal to 225,?,95 percent confidence interval:,?,172.2743 211.3257,?,sample estimates:,?,mean of x,?,191.8,?,P,值,=0.0020960.05,拒绝原假设,认为油漆工人的血小板计数与正常成,年男子有差异。,习题,5.3,为研究某铁剂治疗和饮食治疗营养性缺铁性贫血的效果,将,16,名患者按年龄、,体重、病程和病情相近的原则配成,8,对,分别使用饮
16、食疗法和补充铁剂治疗的,方法,三个月后测得两种患者血红蛋白如表,5.1,所示,问两种方法治疗后的患,者血红蛋白有无差异,.,?,x-c(113,120,138,120,100,118,138,123),?,y-c(138,116,125,136,110,132,130,110),?,t.test(x-y),?,程序结果:,One Sample t-test,?,data:x-y,?,t=-0.65127,df=7,p-value=0.5357,?,alternative hypothesis:true mean is not equal to 0,?,95 percent confidence
17、 interval:,?,-15.628891 8.878891,?,sample estimates:,?,mean of x,?,-3.375,?,P=0.5370.05,接受原假设,两种方法治疗后的患者血红蛋白无差异,例,6.2 P257,(回归方程的显著性检验),求例,6.1,的回归方程,并对相应的方程做检验。,?,x-c(0.1,0.11,0.12,0.13,0.14,0.15,0.16,0.17,0.18,0.20,0.21,0.23),?,y-c(42.0,43.5,45.0,45.5,45.0,47.5,49.0,53.0,50.0,55.0,55.0,60.0),?,lm.s
18、ol-lm(y1+x),?,summary(lm.sol),?,程序结果见下一张,PPT,?,回归方程为:,?,从回归结果可以看出,回归方程通过了回归参数的检验与回归方程,的检验。,?,28.493,130.835,Y,X,?,?,例,6.2,的程序结果,?,程序结果:,Call:,?,lm(formula=y 1+x),?,Residuals:,?,Min 1Q Median 3Q Max,?,-2.0431-0.7056 0.1694 0.6633 2.2653,?,Coefficients:,?,Estimate Std.Error t value Pr(|t|),?,(Intercep
19、t)28.493 1.580 18.04 5.88e-09*,?,x 130.835 9.683 13.51 9.50e-08*-,?,Signif,.codes:0*0.001*0.01*0.05.0.1 1,?,Residual standard error:1.319 on 10 degrees of freedom,?,Multiple R-squared:0.9481,Adjusted R-squared:0.9429,?,F-statistic:182.6 on 1 and 10 DF,p-value:9.505e-08,例,6.4 P260,(预测),求例,6.1,中,X=x0=
20、0.16,时相应的,Y,的概率为,0.95,的,预测区间,?,new-data.frame(x=0.16),?,lm.pred-,predict(lm.sol,new,interval=prediction,level,=0.95),?,lm.pred,?,程序结果:,fit lwr upr,?,49.42639 46.36621 52.48657,?,预测值为,49.43,,预测区间,46.37,52.49,例,6.5 P261,(全面展示一元回归模型的计算过程),Forbes,数据,?,X-matrix(c(194.5,20.79,1.3179,131.79,194.3,20.79,1.3
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 软件 算题 统计学 专业 课件

链接地址:https://www.31ppt.com/p-3865428.html