'rank sum test in R vs. MATLAB: exact p-value when ties are present
Dear masters of R and MATLAB!
As documented, the rank sum test in R can not yield the exact p-value when the data has ties:
x=c(1,1,100,1000,10000);y=c(2,20,20,2000,20000);
result=wilcox.test(x,y,mu=0,paired=FALSE,
conf.level=0.95,exact=TRUE,alternative='greater')
Warning message:
In wilcox.test.default(x, y, mu = 0, paired = FALSE, conf.level = 0.95, :
cannot compute exact p-value with ties
Result
Wilcoxon rank-sum test with continuity correction
data: x and y
W = 10, p-value = 0.7358
alternative hypothesis: true location shift is greater than 0
BUT MATLAB DOES IT:
x=[1,1,100,1000,10000]';y=[2,20,20,2000,20000]';
[p,h,stats]=ranksum(x,y,'alpha',0.05,'method','exact','tail','right')
p = 0.714285714285714
I guess, MATLAB does an illegal thing (pMATLAB = 0.71, not 0.74), BUT i would need to force R to yield the exact p-value (pEXACT = pMATLAB = 0.71) for testing purposes.
Thank you :)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
