Português

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

Test statistic

U = n_1 n_2 + \dfrac{n_1(n_1 + 1)}{2} - R_1

Effect 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

R
wilcox.test(y ~ group, data = df)
Python
stats.mannwhitneyu(a, b, alternative="two-sided")

In Python, stats is scipy.stats and np is numpy.

Variants and alternatives

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

  1. What do you want to do? Compare groups, or one group with a reference value
  2. What kind of response did you measure? Numeric: a measurement, such as weight, time or score
  3. How many groups or measurements? Two groups
  4. Are the groups made of different individuals or the same individuals? Different individuals (independent)
  5. Are the data approximately normal in each group, or are the samples large? No, or the response is ordinal

Open the decision tree