Thomas Farrar
2009-Sep-07 21:00 UTC
[R] Equivalence of Mann-Whitney test and Kruskal-Wallis test with k=2
Hi all, The Kruskal-Wallis test is a generalization of the two-sample Mann-Whitney test to *k* samples. That being the case, the Kruskal-Wallis test with *k*=2 should give an identical p-value to the Mann-Whitney test, should it not? x1<-c(1:5) x2<-c(6,8,9,11) a<-wilcox.test(x1,x2,paired=FALSE) b<-kruskal.test(list(x1,x2),paired=FALSE) a$p.value [1] 0.01587302 b$p.value [1] 0.01430588 The p-values are slightly different (note that there are no ties in the data, so computed p-values should be exact). Can anyone explain the discrepancy? It's been awhile since I studied nonparametric stats and this one has me scratching my head. Many thanks! Tom [[alternative HTML version deleted]]
David Scott
2009-Sep-08 05:01 UTC
[R] Equivalence of Mann-Whitney test and Kruskal-Wallis test with k=2
Thomas Farrar wrote:> Hi all, > > The Kruskal-Wallis test is a generalization of the two-sample Mann-Whitney > test to *k* samples. That being the case, the Kruskal-Wallis test with *k*=2 > should give an identical p-value to the Mann-Whitney test, should it not? > > x1<-c(1:5) > x2<-c(6,8,9,11) > a<-wilcox.test(x1,x2,paired=FALSE) > b<-kruskal.test(list(x1,x2),paired=FALSE) > a$p.value > [1] 0.01587302 > b$p.value > [1] 0.01430588 > > The p-values are slightly different (note that there are no ties in the > data, so computed p-values should be exact). > > Can anyone explain the discrepancy? It's been awhile since I studied > nonparametric stats and this one has me scratching my head. > > Many thanks! > Tom >The continuity correction? It is true by default for wilcox.test and is not apparent in the help for kruskal.test. David Scott -- _________________________________________________________________ David Scott Department of Statistics The University of Auckland, PB 92019 Auckland 1142, NEW ZEALAND Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055 Email: d.scott at auckland.ac.nz, Fax: +64 9 373 7018 Director of Consulting, Department of Statistics