[R] Wilcoxon test

peter dalgaard pdalgd at gmail.com
Wed Aug 8 22:12:30 CEST 2012


On Aug 8, 2012, at 18:16 , BELLAY Juliette wrote:

> Dear list,
> 
> I am facing a problem in my statistical analyses on R.
> My experiments are about plants, I record there growth after each cutting (every 3 weeks).
> 'BC' is for the plant, and '1' to '5' is the time of cutting and recording.
> 
> The data and R script are :
> 
> ""
> BourdCoup <- c(21, 7.2, 9.2, 0, 8.52, 14.7, 8.31, 6.2, 127.05, 115.2, 100.7, 24, 162.64, 136.8, 95.1, 78.93, 104.7, 21.2, 35.8, 21, 66, 103.4, 74.9, 43.8, 32.1, 14.9, 2.1, 14.4, 36.1, 35, 53.2, 28.9, 0,0,0,8.7,2.7,4.2,0,21.2)
> 
> groupBC <- as.factor(rep(c("BC1","BC2","BC3","BC4","BC5"), times=1, each=8))
> 
> BC1 <- BourdCoup[groupBC=="BC1"]
> BC2 <- BourdCoup[groupBC=="BC2"]
> BC3 <- BourdCoup[groupBC=="BC3"]
> BC4 <- BourdCoup[groupBC=="BC4"]
> BC5 <- BourdCoup[groupBC=="BC5"]
> ""
> 
> I therefore realise a wilcoxon test for paired series, and compare them one by one.
> 
> ""
>> wilcox.test(BC1,BC2, paired=T)
> 
>        Wilcoxon signed rank test
> 
> data:  BC1 and BC2
> V = 0, p-value = 0.007813
> alternative hypothesis: true location shift is not equal to 0
> ""
> 
> The problem is that it always gives me the same p-value (0.007813), whatever vectors I try. And when I remove "paired=T" from the script, all p-values differ.
> 
> Could you help me please ?

First of all, that's not actually true:

> wilcox.test(BC1, BC5, paired=TRUE)$p.value
[1] 0.3828125
> wilcox.test(BC1, BC4, paired=TRUE)$p.value
[1] 0.015625

If V=0, then the p-value is 2 * 2^(-8) = 1/128 = 0.0078125. This happens if all differences  have the same sign. And....

> outer(1:5,1:5, Vectorize(function(i,j) sum(sign(M[,i]-M[,j]))))
     [,1] [,2] [,3] [,4] [,5]
[1,]    0   -8   -8   -6    4
[2,]    8    0    8    8    8
[3,]    8   -8    0    8    8
[4,]    6   -8   -8    0    8
[5,]   -4   -8   -8   -8    0

... that is indeed what happens in 8 out of 10 paired comparisons.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list