# Non parametric Wilcoxon Signed Rank test

I have the following data vector(in fact its 2392 data points long):

> (dput(head(data, 35)))
c(0.009917216, 0.158975732, -0.008065753, -0.018648987, 0, 0.283519647,
-0.108234184, 0, -0.151124958, -0.049062385, -0.12970766, 0,
-0.281741056, -0.04834985, -0.025923954, 0.167527783, 0.080834965,
0.457401398, -0.007328027, -0.026647639, 0, 0.146048389, 0.059651004,
-0.115781325, -0.022670935, -0.025330951, -0.011990763, 0, -0.051658383,
-0.054335988, -0.190313988, -0.031937749, -0.000498226, -0.064351546,
0.108053675)


Now I want to do a non parametric wilcoxon signed rank test for this data frame:

> (wilcox.test(data))

Wilcoxon signed rank test with continuity correction

data:  data
V = 1100747, p-value = 8.992e-12
alternative hypothesis: true location is not equal to 0


As you can see V is extremely high and I think its therefore probably wrong. Any recommendations what I am doing wrong? What I personally think is, that my R input could be wrong. Any recommendations how to specify it "much more" for a Non parametric Wilcoxon Signed Rank test. I really appreciate your answer!

-

I see no reason whatever to suspect it's wrong.

You have a huge sample. Why couldn't the statistic be large?

In fact, your statistic is actually on the low side ...

It looks like it's using the "sum of the positive ranks" for the test statistic. It's possible to work out the expected value for n=2392 (assuming no ties/zeroes) -- it's 2392*2393/4 = 1431748

[edit: Under the null hypothesis each rank has a 50-50 chance of getting a + or - sign. The sum of $n$ ranks, $1+2+...+n$ is $n(n+1)/2$. The expected sum of the positive ranks is therefore half that, or $n(n+1)/4$.]

Let's generate some samples to check:

a <- replicate(1000,wilcox.test(rnorm(2392))\$statistic)
hist(a,n=50)


Which is consistent with my calculation. Testing with small samples confirms that the statistic being used is the sum of the positive ranks (one of two common forms of the statistic).

Your statistic is quite some way down the low end. If I generate a normal sample with mean -0.2 and standard deviation 1, I get a test statistic roughly the size of yours.

It may be that you're expecting it to be using a different form of the statistic from the one it's actually using.

-
Thx a lot for your answer! However, I do not understand: How do you come up with this 2392*2393/4 equation? –  Kare Apr 17 '14 at 5:42
Included in an edit to the answer just after the place where I said that. –  Glen_b Apr 17 '14 at 10:28