Alternative for wilcox.test in R

I'm trying to do a significance test using wilcox.test

in R. I want to basically check if the value x

is actually inside / outside the distribution d


I am doing the following:

d = c(90,99,60,80,80,90,90,54,65,100,90,90,90,90,90)

    Wilcoxon rank sum test with continuity correction

data:  60 and d
W = 4.5, p-value = 0.5347
alternative hypothesis: true location shift is not equal to 0

Warning message:
In wilcox.test.default(60, d) : cannot compute exact p-value with ties


and basically the p-value is the same for a wide range of i tests.

I've tried wilcox_test()

from package coin

but I can't seem to get it to work while testing the value against the distribution.

Is there an alternative to this test that does the same and knows how to deal with connections?


source to share

1 answer

How worried are you about inaccurate results? I would assume that the approximation is reasonable for the data giving this size. (I managed to get coin::wilcox_test

it and the results are not much different ...)

d <- c(90,99,60,80,80,90,90,54,65,100,90,90,90,90,90)
pfun <- function(x) {
    suppressWarnings(w <- wilcox.test(x,d)$p.value)
testvec <- 30:120
p1 <- sapply(testvec,pfun)
pfun2 <- function(x) {
    dd <- data.frame(y=c(x,d),f=factor(c(1,rep(2,length(d)))))
p2 <- sapply(testvec,pfun2)
pfun3 <- function(x) {wilcox.exact(x,d)$p.value}
p3 <- sapply(testvec,pfun3)



      xlab="value",ylab="p value of wilcoxon test",lty=1,


enter image description here

( exactRankTests

added upon request, but given that it is no longer supported and recommends a package coin

, I'm not sure how reliable it is). You are on your own to figure out what are the differences between these procedures and which are the best to use ...)

The results make sense here - the problem is that your strength is low. If your value is completely out of the data range, for n = 15 this would be the probability of something like 2 * (1/16) = 0.125 [ie. the probability that your sample will end up as the first or last element in the permutation], which is not exactly the same as the minimum value here ( wilcox.test

: p = 0.105,: wilcox_test

p = 0.08), but that could be an approximation problem, or I may have some errors. However, he is in the right ball.



All Articles