# [Rd] dwilcox (PR#4212)

Mark Lamias Mark.Lamias at grizzard.com
Thu Sep 18 10:48:05 MEST 2003

```Torsten,

Thank you for clarifying.  I see where I have made the mistake.  I failed to

Sorry to inconvenience you.

Sincerely yours,

Mark J. Lamias

-----Original Message-----
From: Torsten Hothorn [mailto:Torsten.Hothorn at rzmail.uni-erlangen.de]
Sent: Thursday, September 18, 2003 3:04 AM
To: mark.lamias at grizzard.com
Cc: r-devel at stat.math.ethz.ch
Subject: Re: [Rd] dwilcox (PR#4212)

> Full_Name: Mark J. Lamias
> Version: 1.7.0
> OS: Windows 2000 Pro
> Submission from: (NULL) (65.222.84.72)
>
>
> I am running the qwilcox procedure and it is producing incorrect results.
For
> example, dwilcox(.025, 3, 5)

not really:

R> dwilcox(.025, 3, 5)
[1] 0

which is natural since the statistic can take integer values only.

> should equal 6, but it is equal to 1.  Similarly,
> dwilcox(.025, 3, 6) should equal 7, but it equals 2.  The critical values
are
> not set being returned with the correct values.  I've verified this with a
> program that performs direct enumeration to determine the appropriate
critical
> values for .05 (two- tail):
>
> n1 n2 n crtical_value
> 3 5 8 6

I think you failed to notice what `?qwilcox' tries to tell you:

This distribution is obtained as follows.  Let 'x' and 'y' be two
random, independent samples of size 'm' and 'n'. Then the Wilcoxon
rank sum statistic is the number of all pairs '(x[i], y[j])' for
which 'y[j]' is not greater than 'x[i]'.  This statistic takes
values between '0' and 'm * n', and its mean and variance are 'm *
n / 2' and 'm * n * (m + n + 1) / 12', respectively.

Moreover, it is documented that `probabilities are P[X <= x]' and
therefore

R> qwilcox(.025, 3, 5) + 3*4/2
[1] 7

means "the smallest x with P(W <= x) => 0.025 is 7" which you can check
easily

R> pwilcox(7 - 3*4/2, 3, 5)
[1] 0.03571429

R> pwilcox(6 - 3*4/2, 3, 5)
[1] 0.01785714

Best,

Torsten

> 3 6 9 7
> 3 7 10 7
> 3 8 11 8
> 3 9 12 8
> 3 10 13 9
> 3 11 14 9
> 3 12 15 10
> 3 13 16 10
> 3 14 17 11
> 3 15 18 11
> 3 16 19 12
> 3 17 20 12
> 3 18 21 13
> 3 19 22 13
> 3 20 23 14
> 3 21 24 14
> 3 22 25 15
> 3 23 26 15
> 3 24 27 16
> 3 25 28 16
> 3 26 29 17
> 3 27 30 17
> 3 28 31 18
> 3 29 32 19
> 3 30 33 19
> 4 4 8 10
> 4 5 9 11
> 4 6 10 12
> 4 7 11 13
> 4 8 12 14
> 4 9 13 14
> 4 10 14 15
> 4 11 15 16
> 4 12 16 17
> 4 13 17 18
> 4 14 18 19
> 4 15 19 20
> 4 16 20 21
> 4 17 21 21
> 4 18 22 22
> 4 19 23 23
> 4 20 24 24
> 4 21 25 25
> 4 22 26 26
> 4 23 27 27
> 4 24 28 27
> 4 25 29 28
> 4 26 30 29
> 4 27 31 30
> 4 28 32 31
> 4 29 33 32
> 4 30 34 33
> 5 5 10 17
> 5 6 11 18
> 5 7 12 20
> 5 8 13 21
> 5 9 14 22
>
> ______________________________________________
> R-devel at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-devel
>
>

```