[R] mannwitney
Knut M. Wittkowski
kmw at mail.rockefeller.edu
Wed May 12 17:48:57 CEST 2004
At 14:12 2004-05-12 +0100, you wrote:
>Hi,
>
>I would like to do a MannWitney test.
>Can anyone help me with the proper command?
>
>Thanks,
>Margarida
You may use wilcox.test or qwilcox, but beware of some subtleties, which
can result in a bit of confusion (see the below comments and it's
discussion in the List in June 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
>
> 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. It might be more
> appropriately be viewed as 'qmannwhitney'.
>
> Here are the rank sums and test statistics for two particular examples:
>
> > 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
>
> > 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
As you can see, the rank sum quantile for the .05 level (two-sided) is 18,
the result of
S> qwilcox(.025,5,5)
[1] 18
while the result of R
R> qwilcox(.025,5,5)
[1] 3
doesn't directly compare to the results of wilcox.test (both R and S).
I hope this helps.
Knut
Knut M. Wittkowski, PhD,DSc
------------------------------------------
The Rockefeller University, GCRC
Experimental Design and Biostatistics
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/clinicalresearch/dept/biometry/
More information about the R-help
mailing list