I know that dunn.test is generally used as a post hoc after Kruskall Wallis to see which groups are different, but to generalize the function I am writing, I was wondering if when only using two groups, under what conditions is the p value from dunn.test equivalent to that of wilcox.test?
For example, if I do:
library(dunn.test) a = rnorm(n=500, m=1.1, sd=1) b = rnorm(n=500, m=1, sd=1)
dunn.test(list(a, b))$P, I get exactly half the result of
wilcox.test(a, b), as dunn.test seems to be doing a one sided test by default. That is easy to fix.
However, when I do:
c = c(0.026448555266779, 0.024129847627784, 0.027900932579116, 0.025760587066198) d = c(0.029862915965958, 0.028563420475972, 0.026703358304031)
Then the p-value of dunn.test is 0.03 (one sided) and wilcox.test is 0.11 (two sided). Is this to be expected? Under what conditions?