The Mann–Whitney U-test is a nonparametric test, also called the Mann–Whitney–Wilcoxon test. It tests for a difference in central tendency of two groups, or, with certain assumptions, for the difference in medians. It is conducted with the wilcox.test function in the native stats package. It can be used with continuous or ordinal measurements.
As another non-parametric alternative to t-tests, a permutation test can be used. An example is shown in the “Permutation test for independent samples” section of this chapter.
Mann–Whitney U-test
###
--------------------------------------------------------------
### Mann–Whitney U-test, biological data analysis class, pp. 128–129
### --------------------------------------------------------------
Input =("
Group Value
2pm 69
2pm 70
2pm 66
2pm 63
2pm 68
2pm 70
2pm 69
2pm 67
2pm 62
2pm 63
2pm 76
2pm 59
2pm 62
2pm 62
2pm 75
2pm 62
2pm 72
2pm 63
5pm 68
5pm 62
5pm 67
5pm 68
5pm 69
5pm 67
5pm 61
5pm 59
5pm 62
5pm 61
5pm 69
5pm 66
5pm 62
5pm 62
5pm 61
5pm 70
")
Data = read.table(textConnection(Input),header=TRUE)
Box plots
boxplot(Value ~ Group,
data = Data,
names=c("2 pm","5 pm"),
ylab="Value")
wilcox.test(Value ~ Group, data=Data)
Wilcoxon rank sum test with continuity correction
W = 186, p-value = 0.1485
# # #
Permutation test for independent samples
Permutation tests are nonparametric tests, and can be performed with the coin package. The permutation test compares values across groups, and can also be used to compare ranks or counts. This test is analogous to a nonparametric t-test. Normality is not assumed but the test may require that distributions have similar variance or shape to be interpreted as a test of means.
###
--------------------------------------------------------------
### Two-sample permutation test, biological data analysis class,
### pp. 128–129
### --------------------------------------------------------------
Input =("
Group Value
2pm 69
2pm 70
2pm 66
2pm 63
2pm 68
2pm 70
2pm 69
2pm 67
2pm 62
2pm 63
2pm 76
2pm 59
2pm 62
2pm 62
2pm 75
2pm 62
2pm 72
2pm 63
5pm 68
5pm 62
5pm 67
5pm 68
5pm 69
5pm 67
5pm 61
5pm 59
5pm 62
5pm 61
5pm 69
5pm 66
5pm 62
5pm 62
5pm 61
5pm 70
")
Data = read.table(textConnection(Input),header=TRUE)
library(coin)
independence_test(Value ~ Group,
data = Data)
Asymptotic General Independence Test
Z = 1.2761, p-value = 0.2019
# # #