# 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)
wilcox.test(60,d)
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

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)
return(w)
}
testvec <- 30:120
p1 <- sapply(testvec,pfun)
library("coin")
pfun2 <- function(x) {
dd <- data.frame(y=c(x,d),f=factor(c(1,rep(2,length(d)))))
return(pvalue(wilcox_test(y~f,data=dd)))
}
p2 <- sapply(testvec,pfun2)
library("exactRankTests")
pfun3 <- function(x) {wilcox.exact(x,d)$p.value}
p3 <- sapply(testvec,pfun3)
```

Photo:

```
par(las=1,bty="l")
matplot(testvec,cbind(p1,p2,p3),type="s",
xlab="value",ylab="p value of wilcoxon test",lty=1,
ylim=c(0,1),col=c(1,2,4))
legend("topright",c("stats::wilcox.test","coin::wilcox_test",
"exactRankTests::wilcox.exact"),
lty=1,col=c(1,2,4))
```

( `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.

source to share