I am trying to duplicate a Wilcoxon signed-rank test example in this Wikipedia post using R.
The data is as follows:
after = c(125, 115, 130, 140, 140, 115, 140, 125, 140, 135)
before = c(110, 122, 125, 120, 140, 124, 123, 137, 135, 145)
sgn = sign(after-before)
abs = abs(after - before)
d = data.frame(after,before,sgn,abs)
d$rank = rank(replace(abs,abs==0,NA), na='keep')
d$multi = d$sgn * d$rank
(W=abs(sum(d$multi, na.rm = T)))
W = 9
However, the test statistic value that R produces (undoubtedly due to some mistake that I am making in setting up the function or interpreting the output) is:
wilcox.test(d$before,d$after, paired = T, alternative = "two.sided", correct=F)
Wilcoxon signed rank test
data: d$before and d$after
V = 18, p-value = 0.5936
alternative hypothesis: true location shift is not equal to 0
This (V=18
) is different from the 9
value in the Wikipedia post.
What am I missing?
"Warning messages: 1: In wilcox.test.default(d$before, d$after, paired = T, alternative = "two.sided", : cannot compute exact p-value with ties"
AND2: In wilcox.test.default(d$before, d$after, paired = T, alternative = "two.sided", : cannot compute exact p-value with zeroes
$\endgroup$