统计学--基于R(第3版)(基于R应用的统计学丛书)作者:贾俊平 习题答案 第五章

5.1

#5.1
#样本均值120,标准差15,95%
q<-qnorm(0.975)#95%的置信水平
LCI<-120-q*(15/sqrt(49))
UCI<-120+q*(15/sqrt(49))
data.frame(LCI,UCI)

5.2

#5.2
#(1)服从正态,标准差500,n=15,平均数8900,置信水平95%
q<-qnorm(0.975)
LCI<-8900-q*(500/sqrt(15))
UCI<-8900+q*(500/sqrt(15))
data.frame(LCI,UCI)
#(2)不服从正态分布,标准差500,n=35,平均数8900,置信水平95%
q<-qnorm(0.975)
LCI<-8900-q*(500/sqrt(35))
UCI<-8900+q*(500/sqrt(35))
data.frame(LCI,UCI)
#(3)不服从正态分布,标准差未知,n=35,平均数8900,s=510,置信水平90%
q<-qnorm(0.95)
LCI<-8900-q*(510/sqrt(35))
UCI<-8900+q*(510/sqrt(35))
data.frame(LCI,UCI)
#(4)不服从正态分布,标准差未知,n=100,平均数8900,s=510,置信水平95%
q<-qnorm(0.975)
LCI<-8900-q*(510/sqrt(100))
UCI<-8900+q*(510/sqrt(100))
data.frame(LCI,UCI)

5.3

#5.3
load('C:/exercise/ch5/exercise5_3.RData')
exercise5_3
library(BSDA)
#置信水平90%
z.test(exercise5_3$上网时间,mu=0,sigma.x=sd(exercise5_3$上网时间),conf.level=0.90)
#置信水平95%
z.test(exercise5_3$上网时间,mu=0,sigma.x=sd(exercise5_3$上网时间),conf.level=0.95)
#置信水平99%
z.test(exercise5_3$上网时间,mu=0,sigma.x=sd(exercise5_3$上网时间),conf.level=0.99)

5.4

#5.4
#95%
N<-500
n<-50
x<-32
p<-x/n
s=N/n
q<-qnorm(0.975)
LCI<-p-q*sqrt(p*(1-p)/n)
UCI<-p+q*sqrt(p*(1-p)/n)
data.frame(LCI,UCI)

5.5

#5.5
load('C:/exercise/ch5/exercise5_5.RData')
exercise5_5
#(1)方式1,均值,95%
t.test(exercise5_5$方式1,conf.level=0.95)
#(2)方式2,方差,95%
library(TeachingDemos)
sigma.test(exercise5_5$方式2,conf.level=0.95)$conf.int
#(3)时间均值差值,95%
#.1)假设方差相等
t.test(x=exercise5_5$方式1,y=exercise5_5$方式2,var.equal=TRUE)$conf.int
#.2)假设方差不相等
t.test(x=exercise5_5$方式1,y=exercise5_5$方式2,var.equal=FALSE)$conf.int

5.6

#5.6
#方差未知但相等,求均值之差,独立小样本
#(1)95%
q<-qnorm(0.975)
LCI<-(53.2-43.4)-q*sqrt(96.8/14+102.0/7)
UCI<-(53.2-43.4)+q*sqrt(96.8/14+102.0/7)
data.frame(LCI,UCI)
#(2)99%
q<-qnorm(0.995)
LCI<-(53.2-43.4)-q*sqrt(96.8/14+102.0/7)
UCI<-(53.2-43.4)+q*sqrt(96.8/14+102.0/7)
data.frame(LCI,UCI)

5.7

#5.7
#均值之差,95%
load('C:/exercise/ch5/exercise5_7.RData')
exercise5_7
t.test(x=exercise5_7$方法1,y=exercise5_7$方法2,paired=FALSE)$conf.int#无法保证正态性假设的情境,可以添加参数paired=TRUE;(独立样本时,paired=FALSE)
#t.test(x=exercise5_7$方法1,y=exercise5_7$方法2)$conf.int#默认是方差不相等
#方差相等:t.test(x=exercise5_7$方法1,y=exercise5_7$方法2,var.equal=TRUE)$conf.int
#方差不相等:t.test(x=exercise5_7$方法1,y=exercise5_7$方法2,var.equal=FALSE)$conf.int

5.8

#5.8
#(1)总体比例之差,90%
p1<-0.4
p2<-0.3
n<-250
q<-qnorm(0.95)
LCI<-p1-p2-q*sqrt(p1*(1-p1)/n+p2*(1-p2)/n)
UCI<-p1-p2+q*sqrt(p1*(1-p1)/n+p2*(1-p2)/n)
data.frame(LCI,UCI)
#(2)总体比例之差,95%
p1<-0.4
p2<-0.3
n<-250
q<-qnorm(0.975)
LCI<-p1-p2-q*sqrt(p1*(1-p1)/n+p2*(1-p2)/n)
UCI<-p1-p2+q*sqrt(p1*(1-p1)/n+p2*(1-p2)/n)
data.frame(LCI,UCI)

5.9

#5.9
#总体方差比,95%
load('C:/exercise/ch5/exercise5_9.RData')
exercise5_9
var.test(exercise5_9$机器1,exercise5_9$机器2,alternative="two.sided")$conf.int

#ps:有错误欢迎指正👀

  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值