全文预览

非参数统计(第二版)习题R程序

上传者:科技星球 |  格式:doc  |  页数:17 |  大小:25KB

文档介绍
ight.high) #方法一:Р wy<-Qiuzhi(weight.low,weight.high)##wy=50 wxy<-wy-n*(n+1)/2;wxy#=22 mean<-m*n/2Р var<-m*n*(m+n+1)/12Р pvalue<-1-2*pnorm(wxy,mean-0.5,var);pvalue #方法二Р wilcox.test(weight.high,weight.low) 例3.4Р Mx-My的R参考程序:Р x1<-c(140,147,153,160,165,170,171,193) x2<-c(130,135,138,144,148,155,168) n1<-length(x1) n2<-length(x2)Р th.hat<-median(x2)-median(x1) B=10000Р Tboot=c(rep(0,1000)) #vector of length Bootstrap for (i in 1:B) {Р xx1=sample(x1,5,T) #sample of size n1 with replacement from x1Р xx2=sample(x2,5,T) #sample of size n2 with replacement from x2Р Tboot[i]=median(xx2)-median(xx1) }Р th<-median(Tboot);th se=sd(Tboot)Р Normal.conf=c(th+qnorm(0.025,0,1)*se,th-qnorm(0.025,0,1)*se);Normal.confР Percentile.conf=c(2*th-quantile(Tboot,0.975),2*th-quantile

收藏

分享

举报
下载此文档