您好,欢迎访问三七文档
当前位置:首页 > 财经/贸易 > 资产评估/会计 > R软件计算题--统计学专业
例4.15P179(一个正态总体的区间估计)为估计一件物体的重量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)•程序结果:•OneSamplet-test•data:x•t=131.59,df=9,p-value=4.296e-16•alternativehypothesis:truemeanisnotequalto0•95percentconfidenceinterval:•9.87722510.222775•sampleestimates:•meanofx•10.05得到的区间估计为:[9.88,10.22]例4.18P185(均值差的区间估计)现从生产线上随机抽取样本x1,x2,···,x12和y1,y2,···,y17,都服从正态分布,其均值分别为u1=201.1,u2=499.7,标准差分别为2.4,4.7。给定置信系数0.95,试求u1-u2的区间估计。•x-rnorm(12,501.1,2.4)•y-rnorm(17,499.7,4.7)•①两样本方差不同t.test(x,y)•程序结果:WelchTwoSamplet-test•data:xandy•t=-0.6471,df=25.304,p-value=0.5234•alternativehypothesis:truedifferenceinmeansisnotequalto0•95percentconfidenceinterval:•-3.6571211.907620•sampleestimates:•meanofxmeanofy•500.7888501.6635•u1-u2的置信系数为0.95的区间估计为[-3.66,1.91]•②方差相同t.test(x,y,var.equal=TRUE)例4.19P186(配对数据情形下均值差的区间估计)抽查患者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,14.7,11.4,13.8,12.0)•t.test(x-y)•程序结果:•OneSamplet-test•data:x-y•t=-1.3066,df=9,p-value=0.2237•alternativehypothesis:truemeanisnotequalto0•95percentconfidenceinterval:•-1.85728810.4972881•sampleestimates:•meanofx•-0.68•治疗前后变化的区间估计为[-1.86,0.497]例4.22P193(一个总体求均值的单侧置信区间估计)从一批灯泡中随机地取5只作寿命试验测得寿命以小时计为10501100112012501280设灯泡的寿命服从正态分布.求灯泡寿命平均值的置信度为0.95的单侧置信下限•x-c(1050,1100,1120,1250,1280)•t.test(x,alternative=greater)•程序结果:OneSamplet-test•data:x•t=26.003,df=4,p-value=6.497e-06•alternativehypothesis:truemeanisgreaterthan0•95percentconfidenceinterval:•1064.9Inf•sampleestimates:•meanofx•1160•95%的灯泡寿命在1064.9小时以上习题4.6P201甲、乙两种稻种分布播种在10块试验田中,每块试验田甲、乙稻种各种一半,假设两稻种产量X,Y均服从正态分布,且方差相等,收获后10块试验田的产量如下所示(单位:千克)。求出两稻种产量的期望差u1-u2的置信区间(a=0.05).•x-c(140,137,136,140,145,148,140,135,144,141)•y-c(135,118,115,140,128,131,130,115,131,125)•t.test(x,y,var.equal=T)•程序结果•TwoSamplet-test•data:xandy•t=4.6287,df=18,p-value=0.0002087•alternativehypothesis:truedifferenceinmeansisnotequalto0•95percentconfidenceinterval:•7.53626120.063739•sampleestimates:•meanofxmeanofy•140.6126.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)•a-rnorm(4,mean(x),var(x))•b-rnorm(5,mean(y),var(y))•t.test(a,b)•程序结果:WelchTwoSamplet-test•data:aandb•t=636.28,df=5.788,p-value=3.028e-15•alternativehypothesis:truedifferenceinmeansisnotequalto0•95percentconfidenceinterval:•0.0020414400.002057343•sampleestimates:•meanofxmeanofy•0.14124940.1392000•区间为:[0.00204,0.00205]例5.2P209(单个正态总体均值的假设检验)某种元件的寿命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)•程序结果:OneSamplet-test•data:x•t=0.66852,df=15,p-value=0.257•alternativehypothesis:truemeanisgreaterthan225•95percentconfidenceinterval:•198.2321Inf•sampleestimates:•meanofx•241.5•计算出P值为0.257大于0.05,所以,接受原假设,即认为元件的平均寿命不大于255小时例5.6P221(二项分布总体的假设检验)有一批蔬菜种子的平均发芽率为P=0.85,现在随机抽取500粒,用种衣剂进行浸种处理,结果有445粒发芽,问种衣剂有无效果。•binom.test(445,500,p=0.85)•程序结果:Exactbinomialtest•data:445and500•numberofsuccesses=445,numberoftrials=500,p-value=0.01207•alternativehypothesis:trueprobabilityofsuccessisnotequalto0.85•95percentconfidenceinterval:•0.85923420.9160509•sampleestimates:•probabilityofsuccess•0.89•P值=0.012070.05,拒绝原假设,认为种衣剂对种子发芽率有显著效果。习题5.1P249正常男子血小板计数均值为225*10^9/L,今测得20名男性油漆作业工人的血小板计数值如下。问油漆工人的血小板计数与正常成年男子有无差异?•x-c(220,188,162,230,145,160,237,188,247,113,126,245,164,231,250,183,190,158,224,175)•t.test(x,alternative=two.side,mu=225)•程序结果:OneSamplet-test•data:x•t=-3.5588,df=19,p-value=0.002096•alternativehypothesis:truemeanisnotequalto225•95percentconfidenceinterval:•172.2743211.3257•sampleestimates:•meanofx•191.8•P值=0.0020960.05,拒绝原假设,认为油漆工人的血小板计数与正常成年男子有差异。习题5.3为研究某铁剂治疗和饮食治疗营养性缺铁性贫血的效果,将16名患者按年龄、体重、病程和病情相近的原则配成8对,分别使用饮食疗法和补充铁剂治疗的方法,三个月后测得两种患者血红蛋白如表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)•程序结果:OneSamplet-test•data:x-y•t=-0.65127,df=7,p-value=0.5357•alternativehypothesis:truemeanisnotequalto0•95percentconfidenceinterval:•-15.6288918.878891•sampleestimates:•meanofx•-3.375•P=0.5370.05,接受原假设,两种方法治疗后的患者血红蛋白无差异例6.2P257(回归方程的显著性检验)求例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.sol-lm(y~1+x)•summary(lm.sol)•程序结果见下一张PPT•回归方程为:•从回归结果可以看出,回归方程通过了回归参数的检验与回归方程的检验。ˆ28.493130.835YX例6.2的程序结果•程序结果:Call:•lm(formula=y~1+x)•Residuals:•Min1QMedian3QMax•-2.0431-0.70560.16940.66332.2653•Coefficients:•EstimateStd.ErrortvaluePr(|t|)•(Intercept)28.4931.58018.045.88e-09***•x130.8359.68313.519.50e-08***---•Signif.codes:0‘***’0.001‘**’0.01‘*’0.05‘.’0.1‘’1•Residualstandarderror:1.319on10degreesoffreedom•MultipleR-squared:0.9481,AdjustedR-
本文标题:R软件计算题--统计学专业
链接地址:https://www.777doc.com/doc-2856453 .html