[R] The W statistic in wilcox.exact

Torsten Hothorn Torsten.Hothorn at rzmail.uni-erlangen.de
Fri Oct 6 08:50:21 CEST 2006


On Thu, 5 Oct 2006, Christos Hatzis wrote:

> Jue,
>
> On a second look, it appears that wilcox.test does report the
> offset-adjusted statistic U, as also mentioned in the help page.
>
> wilcox.test returns W=6 (instead of 12 as your example showed, unless
> "wilcox_test" is a different function).
>
>> wilcox.test( 1:5 ~ c(1,1,0,0,0) )$statistic  # or wilcox.test( 1:5 ~
> factor(c(1,1,0,0,0)) )$statistic
> W
> 6
>
> So there does not appear to be a difference between the two methods.  Did I
> miss something?
>

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

> -Christos
>
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Christos Hatzis
> Sent: Thursday, October 05, 2006 4:41 PM
> To: Jue.Wang2 at sanofi-aventis.com; r-help at stat.math.ethz.ch
> Subject: Re: [R] The W statistic in wilcox.exact
>
> Probably because of the offset:
>
> U = W - n*(n+1)/2
>
> In your example, W=12 (=3+4+5) as reported by wilcox.test.  The offset is 6
> (=3*4/2) and therefore U=6.
> I am not certain as I haven't installed the exactRankTests package, but it
> seems that wilcox.exact reports U instead of W.
>
> -Christos Hatzis
>
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of
> Jue.Wang2 at sanofi-aventis.com
> Sent: Thursday, October 05, 2006 1:35 PM
> To: r-help at stat.math.ethz.ch
> 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
> alternative hypothesis: true mu is not equal to 0
>
>
> (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
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



More information about the R-help mailing list