As a software note, the wilcox.test
function in R does not return the Z value. If the sample size is less than 50 and there are no ties, by default the software computes the p value with an "exact" method, and doesn't compute a Z value at all. In other cases, the function computes the Z value but doesn't report it.
A = c(1,3,5,7,9)
B = c(2,4,6,8,10)
wilcox.test(A, B, exact=TRUE)
### Wilcoxon rank sum test
###
### W = 10, p-value = 0.6905
wilcox.test(A, B, exact=FALSE, correct=FALSE)
### Wilcoxon rank sum test
###
### W = 10, p-value = 0.6015
If one were interested in the Z value, I know a couple of methods to extract it in R. One is to use the coin
package. Another is to use the rcompanion
package (with the caveat that I am the author of that package.)
if(!require(coin)){install.packages("coin")}
if(!require(rcompanion)){install.packages("rcompanion")}
Y = c(A, B)
Group = c(rep("A", length(A)), rep("B", length(B)))
Data=data.frame(Group, Y)
library(coin)
wilcox_test(Y ~ Group, data=Data)
### Asymptotic Wilcoxon-Mann-Whitney Test
###
### Z = -0.52223, p-value = 0.6015
library(rcompanion)
wilcoxonZ(A, B, exact=FALSE, correct=FALSE)
### z
### -0.522
wilcoxonZ(A,B, exact=TRUE)
### z
### NA
The Z value itself doesn't give any more information than the p value does. However, sometimes Z / sqrt(N)
is used as an effect size statistic, often called r.
-0.522 / sqrt((length(A) + length(B)))
### -0.1650709
library(rcompanion)
wilcoxonR(x=Y, g=Group)
### r
### -0.165