若两组数据独立,可以使用wilcoxon秩和检验(mann-whitney u检验),来评估观测是否是从相同的概率分布中抽取的(即,在一个总体中获得更高得分的概率是否比另一个总体要大)wilcox.test(y~x, data),其中,y是一个数值型变量,x是一个二分变量. with(uscrime, by(prob, so, median))so: 0[1] 0.0-so: 1[1] 0.0 wilcox.test(prob ~ so, data=uscrime) wilcoxon rank s m testdata: prob by sow = 81, p-val e = 8.488e-05alternative hypothesis: tr e location shift is not eq al to 0 sapply(uscrime[c("u1","u2")],median)u1 u292 34 with(uscrime, wilcox.test(u1,u2,paried=true)) wilcoxon rank s m test with contin ity correctiondata: u1 and u2w = 2209, p-val e  2.2e-16alternative hypothesis: tr e location shift is not eq al to 0warning message:in wilcox.test.defa lt(u1, u2, paried = true) : cannot comp te exact p-val e with ties states - data.frame(state.region, state.x77) kr skal.test(illiteracy~state.region, data=states) kr skal-wallis rank s m testdata: illiteracy by state.regionkr skal-wallis chi-sq ared = 22.672, df = 3, p-val e = 4.726e-05 #显然,结果表明,美国各个地区的文盲率是各不相同的(p0.001) so rce("") states- data.frame(state.region, state.x77) wmc(illiteracy ~ state.region, data=states, method="holm")descriptive statistics west north central northeast so thn 13.00000 12.00000 9.00000 16.00000median 0. 0. 1. 1.mad 0. 0. 0. 0.m ltiple comparisons (wilcoxon rank s m tests)probability adj stment = holm gro p.1 gro p.2 w p 1 west north central 88.0 8.e-01 2 west northeast 46.5 8.e-01 3 west so th 39.0 1.e-02 *4 north central northeast 20.5 5.e-02 .5 north central so th 2.0 8.0e-05 6 northeast so th 18.0 1.e-02 *signif. codes: 0  0.001 ** 0.01 * 0.05 . 0.1 1#so rce函数下载并执行了定义wmc函数的r脚本.函数的形式wmc(y~a, data, method),其中,y是数值输出变量,a是分组变量, data是包含这些变量的数据框,method指定限制i类误差的方法.代码清单7.17使用的是基于holm提出的调整方法,可以很大程度上控制总体i类误差率.wmc函数首先给出了样本量,样本中位数,每组的绝对中位数,其中,西部地区文盲率最低,南部地区文盲率最高.然后,函数生成了六组统计比较.可以从双侧p看到,南部与其他三个区域有明显差别,但当显著性水平p0.05时,其他三个区域间并没有统计显著的差别.组间差异的非参数检验的基本知识到这就结束了,咱们下期再见!