当前位置:首页 > 统计建模与r软件第八章答案
统计建模与r软件第八章答案
【篇一:统计建模与r软件-第4~9章习题】
x-c(0.1,0.2,0.9,0.8,0.7,0.7) n-length(x) a1-mean(x);
m2-(n-1)/n*var(x) a1-1/(1-a1)-2;a1 [1] 0.3076923 极大似然估计
f-function(a2){sum(log(x))+n/(1+a2)} out-uniroot(f,c(0,1));a2-out$root;a2 [1] 0.211182 4.2 x-c(rep(5,365),rep(15,245),rep(25,150),rep(35,100),rep(45,70),rep(55,45),rep(65,25)) lamda-length(x)/sum(x);lamda [1] 0.05 4.3
取均值即可。
x-c(rep(0,17),rep(1,20),rep(2,10),rep(3,2),rep(4,1)) mean(x) [1] 1
平均为1个。 4.4
obj-function(x){f-c(-13+x[1]+((5-x[2])*x[2]-2)*x[2],-29+x[1]+((x[2]+1)*x[2]-14)*x[2]) ;sum(f^2)} x0-c(0.5,-2) nlm(obj,x0) $minimum [1] 48.98425 $estimate
[1] 11.4127791 -0.8968052 $gradient
[1] 1.411401e-08 -1.493206e-07 $code [1] 1
$iterations
[1] 16 4.5
x-c(54,67,68,78,70,66,67,70,65,69)
t.test(x) #t.test()做单样本正态分布区间估计 one sample t-test data: x
t = 35.947, df = 9, p-value = 4.938e-11
alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: 63.1585 71.6415 sample estimates: mean of x 67.4
平均脉搏点估计为 67.4 ,95%区间估计为 63.1585 71.6415 。
t.test(x,alternative=less,mu=72) #t.test()做单样本正态分布单侧区间估计
one sample t-test data: x
t = -2.4534, df = 9, p-value = 0.01828
alternative hypothesis: true mean is less than 72 95 percent confidence interval: -inf 70.83705
sample estimates: mean of x 67.4
p值小于0.05,拒绝原假设,平均脉搏低于常人。 4.6
x-c(140,137,136,140,145,148,140,135,144,141);x [1] 140 137 136 140 145 148 140 135 144 141
y-c(135,118,115,140,128,131,130,115,131,125);y [1] 135 118 115 140 128 131 130 115 131 125 t.test(x,y,var.equal=true) 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.53626 20.06374
sample estimates: mean of x mean of y 140.6 126.8
期望差的95%置信区间为 7.53626 20.06374 。 4.7
x-c(0.143,0.142,0.143,0.137)
y-c(0.140,0.142,0.136,0.138,0.140) t.test(x,y,var.equal=true) two sample t-test data: x and y
t = 1.198, df = 7, p-value = 0.2699
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval: -0.001996351 0.006096351 sample estimates: mean of x mean of y 0.141250.13920
期望差的95%的区间估计为-0.001996351 0.006096351 4.8 接4.6
var.test(x,y)
f test to compare two variances data: x and y
f = 0.2353, num df = 9, denom df = 9, p-value = 0.04229
alternative hypothesis: true ratio of variances is not equal to 1 95 percent confidence interval: 0.05845276 0.94743902 sample estimates: ratio of variances 0.2353305
var.test可做两样本方差比的估计。此结果可认为方差不等,因此,在4.6中,计算期望差时应该采取方差不等的参数。 t.test(x,y)
welch two sample t-test data: x and y
t = 4.6287, df = 13.014, p-value = 0.0004712
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval: 7.359713 20.240287 sample estimates: mean of x mean of y 140.6 126.8
期望差的95%置信区间为 7.359713 20.240287 。 4.9
x-c(rep(0,7),rep(1,10),rep(2,12),rep(3,8),rep(4,3),rep(5,2)) n-length(x)
tmp-sd(x)/sqrt(n)*qnorm(1-0.05/2) mean(x)
[1] 1.904762
mean(x)-tmp;mean(x)+tmp [1] 1.494041 [1] 2.315483
平均呼唤次数为1.9
0.95的置信区间为1.49,2,32 4.10
x-c(1067,919,1196,785,1126,936,918,1156,920,948) t.test(x,alternative=greater) one sample t-test data: x
t = 23.9693, df = 9, p-value = 9.148e-10
alternative hypothesis: true mean is greater than 0 95 percent confidence interval: 920.8443inf
sample estimates: mean of x 997.1
灯泡平均寿命置信度95%的单侧置信下限为 920.8443 5.1
x-c(220, 188, 162, 230, 145, 160, 238, 188, 247, 113, 126, 245, 164, 231, 256, 183, 190, 158, 224, 175) t.test(x,mu=225)### 双边检验 one sample t-test data: x
t = -3.4783, df = 19, p-value = 0.002516
alternative hypothesis: true mean is not equal to 225 95 percent confidence interval:
共分享92篇相关文档