Statistics Quest

Mann–Whitney U test (Wilcoxon rank-sum)

A rank-based test comparing two independent groups; it tests whether values in one group tend to be larger than in the other.

U1=R1−n1(n1+1)2,U2=n1n2−U1U_1 = R_1 - \frac{n_1(n_1+1)}{2},\qquad U_2 = n_1 n_2 - U_1
U₁ counts the pairs (x, y) with x > y, ties counting ½.
R1R_1
Sum of the ranks of sample 1 in the pooled sample (average ranks for ties).
n1,n2n_1, n_2
Group sizes.
z=U−n1n2/2−cσU,σU2=n1n212[(N+1)−∑(t3−t)N(N−1)]z = \frac{U - n_1 n_2/2 - c}{\sigma_U},\qquad \sigma_U^2 = \frac{n_1 n_2}{12}\left[(N+1) - \frac{\sum (t^3 - t)}{N(N-1)}\right]
Normal approximation (used with ties or large samples); exact null distribution otherwise (no ties, both n ≤ 50).
cc
Continuity correction ½ (default on).
tt
Size of each group of tied values.
NN
n1+n2n_1 + n_2.

When to use

Two independent groups with an ordinal outcome, or a quantitative outcome with small samples and strong skew or outliers (e.g. waiting times, delays).

Assumptions

  • Independent observations within and between groups.
  • Ordinal or continuous outcome. Exact p-values need no ties; with ties the engine uses the tie-corrected normal approximation.
  • To read it as a test of medians, the two distributions must have the same shape (one shifted relative to the other).

How to interpret

H₀: the two distributions are identical, so P(X>Y)=12P(X > Y) = \tfrac12. Report the rank-biserial correlation r=2U1/(n1n2)−1=2P^(X>Y)−1r = 2U_1/(n_1n_2) - 1 = 2\hat P(X > Y) - 1 and group medians.

Common mistakes

  • Describing it as "comparing means".
  • Claiming a difference in medians when the shapes differ (the test responds to any tendency for one group to be larger, including spread differences).
  • Using it for paired data (use the signed-rank test).

Example

x: 3, 5, 7, 9, 11; y: 1, 2, 4, 6. Pooled ranks of x: 3, 5, 7, 8, 9, so R1=32R_1 = 32 and U1=32−15=17U_1 = 32 - 15 = 17 (of 20 pairs, x is larger in 17). Exact two-sided p=0.111p = 0.111; rank-biserial r=0.70r = 0.70. A large effect, but with 9 observations the evidence is weak.