R语言与统计分析第五章习题答案

上传人:桔**** 文档编号:502938913 上传时间:2023-03-26 格式:DOC 页数:3 大小:18.01KB
返回 下载 相关 举报
R语言与统计分析第五章习题答案_第1页
第1页 / 共3页
R语言与统计分析第五章习题答案_第2页
第2页 / 共3页
R语言与统计分析第五章习题答案_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

《R语言与统计分析第五章习题答案》由会员分享,可在线阅读,更多相关《R语言与统计分析第五章习题答案(3页珍藏版)》请在金锄头文库上搜索。

1、#5.1x-c(3,5,7,9,11,13,15,17,19,21)y-c(21,16,15,26,22,14,21,22,18,25)e=sum(x*y)/sum(y) #样本期望d=(sum(x*x*y)/sum(y)-e2 #样本方差a=(8*e+sqrt(64*e2-4*4*(4*e2-12*d)/8 #估计结果b=(8*e-sqrt(64*e2-4*4*(4*e2-12*d)/8ab#5.2x-c(0,1,2,3,4,5,6)y-c(17,20,10,2,1,0,0)f-function()(e(-50*)*50)/(210*62*24) #似然函数optimize(f,c(0,2)

2、,maximum=TRUE)#5.3x-c(482,493,457,471,510,446,435,418,394,469) #0.95置信区间t.test(x)$conf.intchisq.var.test-function(x,var,alpha,alternative=two.sided) options(digits=4) result-list() n-length(x) v-var(x) result$var-v chi2-(n-1)*v/var result$chi2-chi2 p-pchisq(chi2,n-1) result$p.value-p if(alternative=

3、less) result$p.value-pchaisq(chi2,n-1,lower.tail=F) else if (alternative=two.sider) result$p.value-2*min(pchaisq(chi2,n-1),pchaisq(chi2,n-1,lower.tail=F) result$conf.int-c( (n-1)*v/qchisq(alpha/2,df=n-1,lower.tail=F), (n-1)*v/qchisq(alpha/2,df=n-1,lower.tail=T) ) resultchisq.var.test(x,var(x),0.90,a

4、lternative=two.side)$conf.int #0.90置信区间#5.4x-c(25,28,23,26,29,22)y-c(28,23,30,35,21,27)chisq.var.test(x,var(x),0.95,alternative=two.side)$conf.int #卷烟A方差0.95置信区间chisq.var.test(y,var(y),0.95,alternative=two.side)$conf.int #卷烟B方差0.95置信区间#方法二 两方差比0.95的置信区间var.test(x,y)two.sample.ci-function(x,y,conf.le

5、vel=0.95,sigma1,sigama2) #样本方差作为整体方差 options(digits=4) m=length(x) n=length(y) xbar=mean(x)-mean(y) alpha=1-conf.level zstar=qnorm(1-alpha/2)*(sigma1/m+sigma2/n)(1/2) xbar+c(-zstar,+zstar)sigma1-var(x)sigma2-var(y)two.sample.ci(x,y,conf.level=0.95,sigma1,sigma2)#5.5x-c(628,583,510,554,612,523,530,61

6、5,573,603,334,564)y-c(535,433,398,470,567,480,498,560,503,426,338,547)two.sample.ci-function(x,y,conf.level=0.95,sigma1,sigama2) options(digits=4) m=length(x) n=length(y) xbar=mean(x)-mean(y) alpha=1-conf.level zstar=qnorm(1-alpha/2)*(sigma1/m+sigma2/n)(1/2) xbar+c(-zstar,+zstar)sigma1=2140sigma2=32

7、50a-two.sample.ci(x,y,conf.level=0.95,sigma1,sigma2)b-two.sample.ci(x,y,conf.level=0.90,sigma1,sigma2)a2 #置信水平为0.95的置信上限b1 #置信水平为0.90的置信下限#5.6x-c(15.2,14.5,15.5,14.8,15.1,15.6,14.7)y-c(15.2,15.0,14.8,15.2,15.0,14.9,15.1,14.8,15.3)var.test(x,y) #x方差与y方差的比值极大,说明x方差大于y方差#5.7prop.test(224,400,conf.level

8、=0.99,correct=TRUE)#5.8size.norm2-function(s,alpha,d,m) t0-qt(alpha/2,m,lower.tail=FALSE) n0-(t0*s/d)2 t1-qt(alpha/2,n0,lower.tail=FALSE) n10.5) n0-(qt(alpha/2,n1,lower.tail=FALSE)*s/d)2 n1-(qt(alpha/2,n0,lower.tail=FALSE)*s/d)2 n1size.norm2(10,0.05,2,100)#5.8size.bin-function(d,p,conf.level=0.95) alpha=1-conf.level (qnorm(1-alpha/2)/d)2*p*(1-p)size.bin(0.01,0.05,0.90)

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 高等教育 > 习题/试题

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号