统计学R上机4,区间估计与假设检验 (4)_第1页
统计学R上机4,区间估计与假设检验 (4)_第2页
统计学R上机4,区间估计与假设检验 (4)_第3页
统计学R上机4,区间估计与假设检验 (4)_第4页
统计学R上机4,区间估计与假设检验 (4)_第5页
已阅读5页,还剩8页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、4、区间估计和假设检验1 一个总体的均值的区间估计1.1 单个总体均值的区间估计:正态分布,标准差已知zsum.test(mean.x, sigma.x = NULL, n.x = NULL, mean.y = NULL, sigma.y = NULL, n.y = NULL, alternative = c("two.sided", "less“, "greater"), mu = 0, conf.level = 0.95)例6.2:library(PASWR2)zsum.test(2500, sigma.x = 100, n.x = 9,

2、conf.level = 0.95)c(2500-qnorm(0.025,lower.tail=F)*100/sqrt(9),2500+qnorm(0.025,lower.tail=F)*100/sqrt(9) 例6.3 library(PASWR2) zsum.test(39.5, sigma.x = 7.2, n.x = 36, conf.level = 0.99) 1.2 单个总体均值的区间估计:正态分布,标准差未知利用t分布公式:例64library(PASWR2) tsum.test(mean.x=2500, s.x = 100, n.x = 9, conf.level = 0.95

3、)c(2500-qt(0.05/2, 8,lower.tail = F)*100/sqrt(9),2500+qt(0.05/2, 8,lower.tail = F)*100/sqrt(9)例65library(PASWR2)tsum.test(mean.x=39.5, s.x = 7.2, n.x = 36, conf.level = 0.99)1.3 大样本下均值的区间估计例66library(PASWR2)zsum.test(mean.x=3319, sigma.x = 3033.4, n.x = 250, conf.level = 0.98)2 两个总体的均值差的区间估计2.1 两总体均

4、值差的区间估计:方差已知例67library(PASWR2)zsum.test(mean.x, sigma.x = NULL, n.x = NULL, mean.y = NULL, sigma.y = NULL, n.y = NULL, alternative = c("two.sided", "less", "greater"), mu = 0, conf.level = 0.95, .) zsum.test(mean.x=22, sigma.x = sqrt(10), n.x = 25, mean.y = 20, sigma.y

5、= sqrt(10), n.y = 16, conf.level = 0.95)2.2 两总体均值差的区间估计:方差未知但相等例6.8 library(PASWR2)tsum.test(mean.x, s.x = NULL, n.x = NULL, mean.y = NULL, s.y = NULL, n.y = NULL, alternative = c("two.sided", "less", "greater"), mu = 0, var.equal = FALSE, conf.level = 0.95, .)tsum.test

6、(mean.x=22, s.x = sqrt(9), n.x = 25, mean.y = 20, s.y = sqrt(10), n.y = 16, var.equal = TRUE, conf.level = 0.95)2.3 大样本下两总体均值差的区间估计例6.9library(PASWR2)zsum.test(mean.x=650, sigma.x = 120, n.x = 50, mean.y = 480, sigma.y = 106, n.y = 50, conf.level = 0.95) 3 总体比例的区间估计例6.10library(PASWR2)zsum.test(mean

7、.x=0.9, sigma.x = sqrt(0.9*0.1), n.x = 100, conf.level = 0.95)#用prop.test(x,n,p)函数可以算出更准确的值:prop.test(90, 100, conf.level = 0.95)4 两总体比例差的区间估计例6.11library(PASWR2) zsum.test(mean.x=0.48, sigma.x = sqrt(0.48*0.52), n.x = 5000, mean.y = 0.6, sigma.y = sqrt(0.6*0.4), n.y = 2000, conf.level = 0.9) 5 正态总体

8、方差的区间估计例6.12c(14*1.652/qchisq(0.05,14,lower.tail = F),14*1.652/qchisq(0.95,14,lower.tail = F)6 两个正态总体方差比的区间估计例6.13c(64/49/qf(0.01,24,15,lower.tail=F), 64/49/qf(0.01,24,15) 7 样本容量的确定例6.14qnorm(1-0.9545)/2, lower.tail = F)2*252/528 一个总体均值的假设检验8.1 正态总体均值的假设检验:方差已知Z检验:zsum.test(mean.x, sigma.x = NULL, n

9、.x = NULL, mean.y = NULL, sigma.y = NULL, n.y = NULL, alternative = c("two.sided", "less", "greater"), mu = 0, conf.level = 0.95, .)例7.1 :library(PASWR2)zsum.test(mean.x=245, sigma.x = 6, n.x = 30, alternative = "two.sided", mu = 240, conf.level = 0.95)例7.2 li

10、brary(PASWR2)zsum.test(mean.x=245, sigma.x = 6, n.x = 30, alternative = "greater", mu = 240, conf.level = 0.95)直接使用样本数据作假设检验: z.test(x, sigma.x = NULL, y = NULL, sigma.y = NULL, sigma.d = NULL, alternative = c("two.sided", "less", "greater"), mu = 0, paired =

11、FALSE, conf.level = 0.95, .)例: x<-rnorm(100);z.test(x, sigma.x = 1, alternative = "two.sided", mu = 0, conf.level = 0.95)8.2 正态总体均值的假设检验:方差未知t检验例7.3 library(PASWR2)mid<-148.5:151.5; f<-c(10,20,50,20); x_bar=weighted.mean(mid,f)tsum.test(mean.x=x_bar, s.x = sqrt(0.7677), n.x = 100,

12、 alternative = "greater", mu = 150, conf.level = 0.95)直接使用样本数据作假设检验: t.test(x, y = NULL, alternative = c("two.sided", "less", "greater"), mu = 0, paired = FALSE, var.equal = FALSE, conf.level = 0.95, .)mid<-148.5:151.5f<-c(10,20,50,20)x<-rep(mid,f)t.t

13、est(x, alternative = "greater", mu = 150, conf.level = 0.95) 例7.4 :x<-c(202, 209, 213, 198, 206, 210, 195, 208, 200, 207)t.test(x, alternative = "greater", mu = 200, conf.level = 0.95) 8.3 大样本总体均值的假设检验例7.5 library(PASWR2)zsum.test(mean.x=510, sigma.x = 8, n.x = 50, alternative

14、 = "greater", mu = 500, conf.level = 0.95)9 两总体均值之差的假设检验9.1 两总体均值之差的假设检验:方差已知例7.6 library(PASWR2) zsum.test(mean.x=22, sigma.x = sqrt(10), n.x = 25, mean.y = 20,sigma.y = sqrt(10), n.y = 16, alternative = "two.sided", mu = 0, conf.level = 0.95)9.2 两总体均值之差的假设检验:方差未知但相等两总体t检验 例7.7:

15、tsum.test(mean.x=22, s.x = sqrt(9), n.x = 25, mean.y = 20, s.y = sqrt(8), n.y = 16, alternative = "greater", mu = 0, var.equal = TRUE, conf.level = 0.95)两总体t检验 例:在平炉上进行一项试验以确定改变操作方法的建议是否会增加钢的得率。标准方法和的新方法各炼了10炉,得率分别为x<-c(78.1,72.4,76.2,74.3,77.4,78.4,76.0,75.7,76.7,77.3)y<-c(79.1,81.0

16、,77.3,79.1,80.0,79.1,79.1,77.3,80.2,82.1)设这两个样本相互独立,且来自方差相同的正态总体。问建议的新操作方法能否提高得率(显著水平0.05)? mean(x)mean(y)t.test(x, y, alternative = "less", mu = 0, var.equal = TRUE, conf.level = 0.95) 由t检验可知,p=0.0002254<0.05,通过检验,说明新的操作方法能提高效率9.3 大样本下两总体均值差的假设检验:Z检验例7-8zsum.test(mean.x=650, sigma.x =

17、120, n.x = 50, mean.y = 480, sigma.y = 106, n.y = 50, alternative = "two.sided", mu = 0, conf.level = 0.95)10 总体比例、比例差的假设检验10.1 单个总体比例的假设检验例7.9library(PASWR2) zsum.test(mean.x=0.97, sigma.x = sqrt(0.98*0.02), n.x = 400, alternative = "two.sided", mu = 0.98, conf.level = 0.95)或 pr

18、op.test(388, 400, p = 0.98, alternative = "two.sided", conf.level = 0.95)10.2 两个总体比例差的假设检验例7.10library(PASWR2) zsum.test(mean.x=0.48, sigma.x = sqrt(0.48*0.52), n.x = 5000, mean.y = 0.6, sigma.y = sqrt(0.6*0.4), n.y = 2000, alternative = "less", mu = 0, conf.level = 0.95) 11 两个正态

19、总体方差比的假设检验var.test(x, y, ratio = 1, alternative = c("two.sided", "less", "greater"), conf.level = 0.95, .)例:x<-rnorm(100)y<-rnorm(100, mean = 0, sd = 2)var.test(x, y, ratio = 1, alternative = "two.sided", conf.level = 0.95)12 作业(将相应R语句和结果写入word文件中)1、在某乡2

20、万亩水稻中按重复抽样方法抽取400亩,得知平均亩产量为609斤,样本标准差为80斤。要求以95.45%的概率保证程度估计该乡水稻的平均亩产量和总产量的区间范围。(1)R程序:library(PASWR2)zsum.test(609, sigma.x = 80, n.x = 400, conf.level = 0.95.45)c(609-qnorm(0.02275,lower.tail=F)*80/sqrt(400),609+qnorm(0.02275,lower.tail=F)*80/sqrt(400) (2)程序结果:(3)结果分析以95.45%概率保证程度该乡的水稻的平均亩产量是(601,

21、617).总产量的区间范围是(12020000,12340000)2、在4000件成品中抽取200件进行检查结果有废品8件,在置信水平0.9545下估计这批成品废品量的范围。(1)R程序prop.test(8, 200, conf.level = 0.9545)(2)运行结果(3)结果分析在0.9545的概率保证程度这批成品废品量的范围在(74,324)3、某单位按简单随机重复抽样方式抽取40名职工,对其业务情况进行考核,考核成绩(单位:分)资料如下:x<-c(68,89,88,84,86,87,75,73,72,68,75,82,99,58,81,54,79,76,95,76,71,6

22、0,91,65,76,72,76,85, 89,92,64,57,83,81,78,77,72,61,70,87)(1) 以95.45%的概率保证程度推断全体职工业务考试成绩的区间范围;R程序a<-mean(x)b<-sd(x)c(a-qnorm(0.02275,lower.tail=F)*b/sqrt(40),a+qnorm(0.02275,lower.tail=F)*b/sqrt(40)输出结果(2)若其它条件不变,将允许误差范围缩小一半,应抽取多少名职工? 因为允许误差缩小一半,因此样本增加四倍,应抽取160名职工。4、根据第3题数据作假设检验(=0.05):(1)全体职工业

23、务考试成绩的平均数是否等于78。t.test(x, alternative = "two.side", mu = 78, conf.level = 0.95)这是一个总体方差未知的总体均值假设检验,根据t检验,p=0.49>0.05,接受原假设,说明在置信度为0.05下,全体职工业务考试成绩的平均数是等于78。(2) 全体职工业务考试成绩的平均数是否大于80。t.test(x, alternative = "greater", mu = 80, conf.level = 0.95)这是一个总体方差未知的总体均值假设检验,根据t检验,p=0.9646>0.05,接受原假设,说明在置信度为0.05下,全体职工业务考试成绩的平均数大于78。(3) 全体职工业务考试成绩的平均数是否小于73。(4) t.test(x, alternative = "

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论