[R] Wilcoxon test p value with one decimal place

Ted Harding Ted.Harding at wlandres.net
Thu Feb 16 19:57:11 CET 2012


On 16-Feb-2012 Bert Gunter wrote:
> On Thu, Feb 16, 2012 at 10:15 AM, Jun Shen <jun.shen.ut at gmail.com> wrote:
>> Dear list,
>>
>> Let's say I have data
>>
>> _a=c(37.961,38.214,57.68)
>> _b=c(77.56,61.875,67.683)
>>
>> 
>>
>> the wilcoxon test only gives me a p value with one decimal place. Is this
>> normal?
> 
> No, it's discrete  :-)
> 
> (Actually, that's the answer. Read up on the Mann-Whitney test to see why).
> 
> -- Bert
> 
> Thanks.
>> Jun

To expand on Bert's reply:

Given two sets of 3 numbers (x,y,z), (X,Y,Z) with x < y < z
and X < Y < Z, there are exactly 20 ways to merge them together
(according to possible relationships between the values in the
first and the second):

  x < y < z < X < Y < Z
  x < y < X < z < Y < Z
  x < y < X < Y < z < Z
  x < y < X < Y < Z < z
  [and so on until]
  X < Y < x < Z < y < z
  X < Y < Z < x < y < z

Your example  is the first of these so has probability 1/20.
Since the default for wilcox.test is "two.sided", the result
takes into account also arrangements which are at least as
extreme as the one given, of which the only case is the last
one in the above list, which also has probability 1/20.

Hence the 2-sided P-value is 1/20 + 1/20 = 1/10, which is
exactly 0.1, as returned by wilcox.test(). It would be possible
to display the result as 0.10000, say, but there is no point!

If you do

  wilcox.test(a,b, alternative="less")

then you will get 0.05 as P-value -- again exactly right.

Ted.

-------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at wlandres.net>
Date: 16-Feb-2012  Time: 18:57:08
This message was sent by XFMail



More information about the R-help mailing list