资源描述
,*,*,单击此处编辑母版标题样式,单击此处编辑母版文本样式,第二级,第三级,第四级,第五级,*,*,*,*,1,两总体的比较与检验,:Wilcoxon,秩和检验法、,Mann-whitney U,检验、,mood,检验,2,两总体的比较与检验,:Wilcoxon,秩和检验法、,Mann-whitney U,检验、,mood,检验,3,一、,Wilcoxon,秩和检验法,例子,1,:为了检验一种新的复合肥和原来使用的肥料相比较是否显著的提高小麦的产量,在一个农场中选择了,10,块田地,每块田地分为两部分,其中任指定一部分使用新的复合肥料,另外一部分使用原肥料,小麦成熟后称得各部分小麦产量如下表。试用,Wilcoxon,秩和检验法检验新的复合肥是否会显著提高小麦的产量,田地,1 2 3 4 5 6 7 8 9 10,新复合肥,459 367 303 392 310 342 421 446 430 412,原肥料,414 306 321 443 281 301 353 391 405 390,4,x y t.test(x,y),Welch Two Sample t-test,data:x and y,t=1.1143,df=18,p-value=0.2798,alternative hypothesis:true difference in means is not equal to 0,95 percent confidence interval:,-24.52442 79.92442,sample estimates:,mean of x mean of y,388.2 360.5,一、,Wilcoxon,秩和检验法,在正太总体的假定下,两样本的均值检验通常用,t,检验。和单样本情况一样,,t,检验并不稳健,在不知总体分布时,使用,t,检验可能有风险。这时就要使用非参数检验:,Wilcoxon,秩和检验法,5,一、,Wilcoxon,秩和检验法,Wilcoxon,秩和检验法:用来检验两样本的位置参数关系,充分利用了样本中秩的信息。,设,X1,、,X2.Xm,为来自连续型总体,X,的容量为,m,的样本,,Y1,、,Y2Yn,为来自连续型总体,Y,的容量为,n,的样本,且两样本相互独立。记,Mx,为总体,X,的中位数,,My,为总体,Y,的中位数。,Wilcoxon.test,()的调用格式:,Wilcox.test(x,y,alternative=c(“two side”,“less”,“greater”),mu,paired,exact,correct=TURE/FALSE,conf.int,conf.level=0.95),Alternative,是备择假设,分为单侧检验和双侧检验,mu,是待检参数;,paired,是逻辑变量,说明变量,x,,,y,是否成对数据,exact,是逻辑变量,说明是否精确计算,P,值,当样本量较少时,此参数起作用,当样本量较大时,软件采用正太分布近似计算,P,值,correct,是逻辑变量,说明是否对,P,值得计算采用连续性修正;,conf.int,是逻辑变量,说明是否给出相应的置信区间。,6,一、,Wilcoxon,秩和检验法,X-c(459,367,303,392,310,342,421,446,430,412),y0.05,,无法拒绝原假设,此结果表明,在,=0.05,的水平下,就所给数据而言,符号检验还不足区分两种肥料对提高小麦的产量产生差异。,7,一、,Wilcoxon,秩和检验法,符号检验计算,binom.test(sum(xy),length(x),alternative=greater),Exact binomial test,data:sum(x y)and length(x),number of successes=8,number of trials=10,p-value=0.05469,alternative hypothesis:true probability of success is greater than 0.5,95 percent confidence interval:,0.4930987 1.0000000,sample estimates:,probability of success,0.8,比较两个计算结果,可以发现,,Wilcoxon,秩和检验法比符号检验在探测差异性方面更有效。,8,二、,Mann-Whitney U,检验,与,Wilcoxon,秩和统计量等价的有,Mann-Whitney U,统计量。令,Wxy,为把所有的,X,的观察值和,Y,的观察值做比较之后,,Y,的观察值大于,X,的观察值的个数,称,Wxy,为,Mann-Whitney U,统计量。,9,二、,Mann-Whitney U,检验,例子,2,:有糖尿病的和正常的老鼠体重为:,糖尿病鼠:,42,44,38,52,48,46,34,44,38,正常老鼠:,34,43,35,33,34,26,30,31,31,27,28,27,30,37,32,检验这两组的体重是否显著不同(,=0.05,)?,10,二、,Mann-Whitney U,检验,x-c(42,44,38,52,48,46,34,44,38),y-c(34,43,35,33,34,26,30,31,31,27,28,27,30,37,32),wilcox.test(x,y,exact=FALSE,correct=FALSE,),Wilcoxon rank sum test,data:x and y,W=128,p-value=0.0003008,alternative hypothesis:true location shift is not equal to 0,correct,是逻辑变量,说明是否对,P,值得计算采用连续性修正;,11,二、,Mann-Whitney U,检验,x-c(42,44,38,52,48,46,34,44,38),y-c(34,43,35,33,34,26,30,31,31,27,28,27,30,37,32),wilcox.test(x,y,exact=FALSE),Wilcoxon rank sum test with continuity correction,data:x and y,W=128,p-value=0.0003374,alternative hypothesis:true location shift is not equal to 0,结论:因为,P,值为,0.0003008=0.05,故拒绝原假设,认为这两组的体重显著不同。,12,三、,Mood,检验,位置参数描述了总体的位置,而描述总体概率分布离散程度的参数是尺度参数。假定两独立样本,X1,,,X2,,,.Xm,和,Y1,,,Y2Yn,分别来自,N,(,1,,,2 1,)和,N,(,2,,,2 2,),则检验,H0,:,2 1 =2 2,最常用的传统的统计方法是,F,检验。在零假设成立时,它服从自由度为(,m-1,n-1,)的,F,分布。但是在总体不是正太或数据有严重的污染时,,F,检验就不合适。则,mood,检验就是用来检验两样本尺度参数之间关系的一种非参数方法。,13,三、,Mood,检验,例子,3,:两个村农民的月收入分别为(元),A,村:,321,266,256,388,330,329,303,334,299,221,365,250,258,342,343,298,238,317,354,B,村:,488,598,507,428,807,342,512,350,672,589,665,549,451,481,514,391,366,468,问两个村农民的月收入的内部差异是否相同?(,=0.05,),14,三、,Mood,检验,Ac(321,266,256,388,330,329,303,334,299,221,365,250,258,342,343,298,238,317,354),Bc(488,598,507,428,807,342,512,350,672,589,665,549,451,481,514,391,366,468),diff-median(B)-median(A),A-A+diff,mood.test(A,B),Mood two-sample test of scale,data:A and B,Z=-2.4846,p-value=0.01297,alternative hypothesis:two.sided,结论:,P,值,0.01297=0.05,故拒绝原假设,认为这两个村的内部差异是不同的。,因为,mood,检验需要的假定之一是要两样本的中位数相同,故在做检验时要先消除两样本之间中位数的差异,接着才可以做,mood,检验,.,15,三、,Mood,检验,A-c(321,266,256,388,330,329,303,334,299,221,365,250,258,342,343,298,238,317,354),B-c(488,598,507,428,807,342,512,350,672,589,665,549,451,481,514,391,366,468),Median,(,A,):,317,Median,(,B,):,497.5,diff-median(B)-median(A),A-A+diff,16,三、,Mood,检验,A-c(321,266,256,388,330,329,303,334,299,221,365,250,258,342,343,298,238,317,354),B-c(488,598,507,428,807,342,512,350,672,589,665,549,451,481,514,391,366,468),mood.test(A,B),Mood two-sample test of scale,data:A and B,Z=-0.1929,p-value=0.8471,alternative hypothesis:two.sided,17,敬请老师同学们批评指正!,
展开阅读全文