[R] qwilcox
    Knut M. Wittkowski 
    kmw at rockefeller.edu
       
    Wed Jun 11 04:53:02 CEST 2003
    
    
  
The function 'wilcox.test' in R and S gives (almost) identical results (see 
below). 'qwilcox' however, does not:
 > qwilcox(p,5,5)
p:      0.025   0.975
--------------------
R>       3      22
S>      18      37
I originally wanted to ask a questions, but then I found the answer. Given 
the confusion I run into, I wonder if this experience is worth reporting.
The S-Plus quantiles are almost correct (they are the limits of the region 
of acceptance, rather than the quantiles). The description in the R help file
         Distribution of the Wilcoxon Rank Sum Statistic
suggests that R:qwilcox also gives quantiles for the rank sum (which the 
Wilcoxon rank sum test is based on). In fact, however, it gives quantiles 
for the u-statistic (which the Mann-Whitney test is based upon). While the 
tests are logically equivalent, the particular test statistics
         - sum(Xi>c(X,Y))        rank sum (Wilcoxon)
         - sum(Xi>c(  Y))        u statistic (Mann-Whitney)
are different (apologies for the non-standard notation). Since 
"wilcox.test" relates to the rank sums in both R and S, as does qwilcox in 
S, the name 'qwilcox' in R may be misleading. How about renaming it to 
'qmannwhitney' instead and adding 'qwilcoxon' for a function that 
corresponds to S:qwilcox?
 > x1 <- c(1,2,3,  5,6         )
 > x2 <- c(      4,    7,8,9,10)
 > sum(x1)
[1] 17
 > sum(x2)
[1] 38
R> wilcox.test(x1,x2,alternative="two.sided")
         Wilcoxon rank sum test: p-value = 0.03175
R> wilcox.exact(x1,x2,alternative="two.sided")
         Exact Wilcoxon rank sum test: p-value = 0.03175
S> wilcox.test(x1,x2,alternative="two.sided")
         Exact Wilcoxon rank-sum test: p-value = 0.0317
 > x1 <- c(1,2,  4,5,6         )
 > x2 <- c(    3,      7,8,9,10)
 > sum(x1)
[1] 18
 > sum(x2)
[1] 37
R> wilcox.test(x1,x2,alternative="two.sided")
         Wilcoxon rank sum test: p-value = 0.05556
R> wilcox.exact(x1,x2,alternative="two.sided")
         Exact Wilcoxon rank sum test: p-value = 0.05556
S> wilcox.test(x1,x2,alternative="two.sided")
         Exact Wilcoxon rank sum test: p-value = 0.0556
Knut M. Wittkowski, PhD,DSc
------------------------------------------
The Rockefeller University, GCRC
1230 York Ave #121B, Box 322, NY,NY 10021
+1(212)327-7175, +1(212)327-8450 (Fax)
kmw at rockefeller.edu
http://www.rucares.org/statist/
    
    
More information about the R-help
mailing list