Mann-Whitney U test
Ranks (nonparametric) · Two independent samples · reference distribution: U (normal for large n)
When to use it
Compare two independent groups when the data are not normal, have extreme values or are ordinal.
Null hypothesis
A value drawn from one group is equally likely to be larger or smaller than one from the other.
Assumptions
- Independent groups
- At least ordinal variable
Test statistic
U = n_1 n_2 + \dfrac{n_1(n_1 + 1)}{2} - R_1Effect size
r, from the z of the normal approximation (N is the total of both samples); the rank-biserial correlation is another option.
r = \dfrac{|z|}{\sqrt{N}}How to report it
U = 112, z = −2.38, p = .017, r = .38
In R and Python
wilcox.test(y ~ group, data = df)
stats.mannwhitneyu(a, b, alternative="two-sided")
In Python, stats is scipy.stats and np is numpy.
Variants and alternatives
- Also called the Wilcoxon rank-sum test
- Parametric version: Two-sample t
Where it sits in the catalog
Ranks (nonparametric). Nonparametric tests assume no distribution for the data. They replace each value by its rank, its position in order (1st, 2nd, 3rd…), which protects them from extreme values and makes them fit ordinal data.
Two independent samples. Two groups of different individuals, unrelated to each other, such as treatment and control.
In the decision tree
- What do you want to do? Compare groups, or one group with a reference value
- What kind of response did you measure? Numeric: a measurement, such as weight, time or score
- How many groups or measurements? Two groups
- Are the groups made of different individuals or the same individuals? Different individuals (independent)
- Are the data approximately normal in each group, or are the samples large? No, or the response is ordinal