The Mann-Whitney U test (also known as Wilcoxon rank-sum test) allows for comparison of two groups which do not necessarily originate from normal distributions. This means that you may use this test even if the samples have a normal distribution. This is thus a good alternative to Student’s t-test when the assumption of normality might constitute a problem.
The function to use in R is wilcox.test(x, y)
where x
and y
are the vectors containing the samples. Let’s use the same example as we have use for Student’s t-test:
wilcox.test(Location_A, Location_B)
## Warning in wilcox.test.default(Location_A, Location_B): cannot compute
## exact p-value with ties
##
## Wilcoxon rank sum test with continuity correction
##
## data: Location_A and Location_B
## W = 15, p-value = 0.2496
## alternative hypothesis: true location shift is not equal to 0
So, the test results in a p-value greater than 0.05, thus indicating that the null hypothesis is not to be rejected. The sample means are not significantly different.