[R] 2 sample wilcox.test != kruskal.test

Meyners, Michael meyners.m at pg.com
Wed Jan 11 12:38:56 CET 2012


The devil is in the details (and in the arguments in Lukasz code). The defaults for the two functions are different: wilcox.test uses an exact test (which is not available in kruskal.test afaik) for your data, and uses the continuity correction if the normal approximation is requested (neither available in kruskal.test). See the manual (in particular ?wilcox.test) for details, or the pertinent literature for the theoretical background.

HTH, Michael


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Lukasz Reclawowicz
> Sent: Wednesday, January 11, 2012 12:00
> To: syrvn
> Cc: r-help at r-project.org
> Subject: Re: [R] 2 sample wilcox.test != kruskal.test
> 
> 2012/1/11 syrvn <mentor_ at gmx.net>
> 
> > Hi,
> >
> > thanks for your answer. Unfortunately I cannot reproduce your
> results.
> >
> > In my example the results still differ when I use your approach:
> >
> > > x <- c(10,11,15,8,16,12,20)
> > > y <- c(10,14,18,25,28,30,35)
> > > f <- as.factor(c(rep("a",7), rep("b",7))) d <- c(x,y)
> > > kruskal.test(x,y)
> >
> 
> Try to compare  wilcox.test and right formula in kruskal, I got:
> > all.equal(wilcox.test(x,y, correct =
> F,exact=F)$p.value,kruskal.test(d~f)$p.value)
> [1] TRUE
> 
> --
> Mi³ego dnia
> 
> 	[[alternative HTML version deleted]]



More information about the R-help mailing list