[R] The W statistic in wilcox.exact

Knut M. Wittkowski kmw at rockefeller.edu
Thu Nov 16 16:35:17 CET 2006


> 

Jue:

In R, wilcox.test does not actually do the Wilcoxon, but the Mann Whitney test.
While the tests are equivalent, the former is based on the rank sum, while the
latter is based on the sum of u-scores. Thus the need to convert the rank sum
into the sum of u-scores. 

In S, in contrast, wilcox.test is based on the rank sums, so that no
conversation is needed.

wilcox_test does, in fact, the Wilcoxon test in R as well, as does the more
general pearson.test, available from http://muStat.rockefeller.edu (click on
downloads after login).

HTH,
Knut

Torsten Hothorn <Torsten.Hothorn <at> rzmail.uni-erlangen.de> writes:
> 
> wilcox.{exact,test} compute the sum of the ranks 3, 4 and 5 minus a 
> constant
> 
>      STATISTIC <- sum(r[seq(along = x)]) - n.x * (n.x + 1)/2
> 
> whereas the linear statistic in wilcox_test (package coin) is equivalent 
> to
> 
>      sum(r[seq(along = x)]) (only sum of the ranks).
> 
> Best,
> Torsten
> 
> > -----Original Message-----
> > Jue.Wang2 <at> sanofi-aventis.com
> > Sent: Thursday, October 05, 2006 1:35 PM
> > Subject: [R] The W statistic in wilcox.exact
> >
> > Does anyone know why wilcox.exact gives W-statistic 6 instead of 12 as
> > indicated below.
> >
> > 12 is the rank sum of group 0 of x, which is the linear statistic computed
> > by wilcox_test.
> >
> > y<-c(1,2,3,4,5)
> > x<-c(1,1,0,0,0)
> >
> > (a) wilcox.exact
> >
> > wilcox.exact(y~x)
> > Exact Wilcoxon rank sum test
> > data:  y by x
> > W = 6, p-value = 0.2
> >
> > (b) wilcox_test
> >
> > tt<-wilcox_test(y~factor(x),distribution="exact")
> > statistic(tt,"linear")
> >
> > 0 12
> >
> > Jue Wang, Biostatistician
> > Contracted Position for Preclinical & Research Biostatistics PrO Unlimited
> > (908) 231-3022



More information about the R-help mailing list