文档详情

R软件课后习题解第四章 -R软件课后习题解第四章 -.doc

发布:2018-04-24约1.72万字共20页下载文档
文本预览下载声明
习题4.1 计算代码如下(极大似然估计): x-c(0.1,0.2,0.9,0.8,0.7,0.7) n- length(x) f-function(a){n/(a+1)+sum(log(x))} uniroot(f,c(0,1)) $root [1] 0.211182 $f.root [1] -3.844668e-05 $iter [1] 5 $estim.prec [1] 6.103516e-05 习题4.2(指数分布) x-c(5,15,25,35,45,55,65) v-c(365,245,150,100,70,45,25) y-x*v f-function(k){1000/k-sum(y)} uniroot(f,c(0,100)) $root [1] 0$f.root [1] -10.46586 $iter [1] 14 $estim.prec [1] 6.103516e-05 估计值为0习题4.3(极大似然估计)(作业) 解:设为字样的一组观测值,所以似然函数为 取对数,所以 求偏导,并令其等于0, 解得,,所以的极大似然估计量为. x-rep(0:6,c(17,20,10,2,1,0,0)) mean(x) [1] 1 习题4.4 y-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(y,x0) $minimum [1] 48.98425 $estimate [1] 11.4127791 -0.8968052 $gradient [1] 1.415447e-08 -1.435296e-07 $code [1] 1 $iterations [1] 16 习题4.5 X- c(54,67,68,78,70,66,67,70,65,69) t.test(X) 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 因此,10名患者平均脉搏在95%的置信区间为[63.16,71.64] 10个人的平均脉搏为67.4,所以这10名患者的平均脉搏属不低于正常人的平均脉搏 习题4.6(作业) 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) 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 所以u1-u2的置信区间为[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) ## 注意:如果方差相同,需要声明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.14125 0.13920 习题4.8(作业) x-c(140,137,136,140,145,148,140
显示全部
相似文档