Worked nonparametric example

The Mann–Whitney U test does not automatically compare medians.

It ranks two independent groups and counts cross-group wins. A clean median-shift interpretation requires the additional claim that the population distributions have the same shape and differ only in location.

15 observations2 independent groupsExact two-sided test8-minute read

The short answer

Interpret ranks first; interpret a location shift only when justified.

For every observation in group A, compare it with every observation in group B. The Mann–Whitney statistic counts how often A is larger, with half credit for ties. It therefore answers whether values in one population tend to rank above values in the other—not whether two sample medians happen to be different.

Interpretation rule: report U and a rank-based effect such as the probability of superiority. Report a Hodges–Lehmann location shift only when a shift model is scientifically and graphically plausible.

The canonical chorioamnion example

R's official wilcox.test documentation reproduces Hollander and Wolfe's permeability constants for human chorioamnion: ten measurements at term and five measurements at 12–26 weeks gestational age. The source's scientific alternative is greater permeability at term.

Group All observations Median
Term (n = 10) 0.80, 0.83, 1.89, 1.04, 1.45, 1.38, 1.91, 1.64, 0.73, 1.46 1.415
12–26 weeks (n = 5) 1.15, 0.88, 0.90, 0.74, 1.21 0.900
Chorioamnion permeability observations by gestational group Ten term observations and five earlier-gestation observations are shown with median bars. Term values tend to rank higher, but both groups overlap. Term 0.80 Term 0.83 Term 1.89 Term 1.04 Term 1.45 Term 1.38 Term 1.91 Term 1.64 Term 0.73 Term 1.46 12–26 weeks 1.15 12–26 weeks 0.88 12–26 weeks 0.90 12–26 weeks 0.74 12–26 weeks 1.21 0.7 1.1 1.5 1.9 Term 12–26 weeks Permeability constant
All 15 observations; horizontal bars mark sample medians. The rank test uses every cross-group ordering, not only these two bars.

What U = 35 means

Ten term values crossed with five earlier values create 50 pairwise contests. The term value is larger in 35 of them, so U = 35 and the sample probability of superiority is 35/50 = 0.700. Equivalently, the rank-biserial correlation is 2 × 0.700 − 1 = 0.400.

Under exchangeability, all ways to allocate ten of the 15 pooled ranks to the term group form the exact null distribution. There are C(15,10) = 3,003 allocations. Doubling the tail at least as extreme as U = 35 gives the default two-sided result: exact P = 0.2544.

Direction must be pre-specified: the official R example requests the one-sided “term is greater” alternative; its exact P is 0.1272. Plotwright's linked project uses the default two-sided test. Do not choose one-sided inference after looking at the direction of the data.

Why the median difference is not the tested effect

The sample medians differ by 1.415 − 0.900 = 0.515. But the Hodges–Lehmann estimate—the median of all 50 term-minus-earlier differences—is 0.305, with a 95% interval from −0.150 to 0.760 in Plotwright's normal-approximation interval. These are different estimands.

If the two population distributions have the same shape and spread and differ only by a location shift, that shift moves the median as well, and the rank result can support a median-shift interpretation. If shapes or spreads differ, a small P value can arise without a simple difference in population medians.

Do not choose it from a normality-test P value

  • Start with the estimand: mean difference, quantile difference, stochastic ordering or a location shift are not interchangeable.
  • Check independence from the design. Paired observations require a paired method; ranking does not erase pairing.
  • Plot raw values and group distributions. “Nonparametric” does not mean assumption-free.
  • Choose exact versus asymptotic inference deliberately. Ties, sample size and software conventions can change the reported P value.
Historical-data caveat: this small placental membrane dataset is a calculation benchmark. The source excerpt does not provide enough design or clinical context to support a modern biological conclusion.

A compact reporting template

“Permeability constants were compared between the term (n = 10) and 12–26-week (n = 5) groups using a two-sided exact Mann–Whitney test, U = 35, P = 0.2544. A term observation exceeded an earlier observation in 70.0% of cross-group pairs (rank-biserial r = 0.400). Under a location-shift interpretation, the Hodges–Lehmann shift was 0.305 (95% CI −0.150 to 0.760).”

What Plotwright checks

Plotwright submits all 15 values to the production Mann–Whitney engine. The published-example gate independently enumerates all 3,003 rank allocations and checks U, the exact two-sided P value, group medians, Hodges–Lehmann shift and interval, probability of superiority and rank-biserial correlation.

Those checks establish the defined calculation. They cannot establish independence, justify a location-shift model or choose a one-sided alternative for the researcher.

Sources and reproducibility

  1. R stats documentation: wilcox.test—the canonical values, two-sample rank-sum definition, directional example and distinction between a location shift and the difference of sample medians.
  2. NIST/SEMATECH: Mann–Whitney U—pooled ranks, rank sums, U and null-distribution logic.
  3. Hart (2001): not just a test of medians—why differences in distribution spread matter to the interpretation.
  4. Plotwright statistical validation—published expected values, tolerances and evidence limits.

Keep raw values, ranks and effect estimates together.

Plotwright opens the complete two-column dataset, Mann–Whitney analysis and editable graph in one local project.