MerQuR+Statistics Glossary

Statistics Glossary → Mann-Whitney U

Mann-Whitney Uanalysis

A test that needs no normality: it converts the values of two independent groups to ranks and compares them, testing whether one group's values tend systematically to be larger than the other's.

Concept

The independent-samples t-test compares means and, in small samples, assumes normality. When the data are skewed, contain outliers or were collected only on an ordinal scale (e.g. a 1-5 satisfaction rating), this assumption weakens. The Mann-Whitney U test (also known as the Wilcoxon rank-sum test) uses the ranks of the values instead of the values themselves; a few extreme values therefore cannot dominate the result, and no assumption about the shape of the distribution is needed.

All observations from both groups are ranked together from smallest to largest, and each receives a rank number; tied values receive the average rank. If there is no difference between the groups, their mean ranks should be close. The U statistic counts in how many pairs an observation from one group exceeds an observation from the other. U divided by its largest possible value gives the probability that a randomly chosen member of the first group exceeds a randomly chosen member of the second; 50% means no difference.

The exact hypothesis tested is that a value from one group is as likely to be larger than a value from the other as it is to be smaller (stochastic equality). Reading the result as 'the medians differ' is correct only when the two distributions have similar shape and spread, that is, when one is a shifted copy of the other. Observations must be independent. Measures such as the rank-biserial correlation and the Hodges-Lehmann location shift show the size of the difference separately from the p value.

When to use it

  • When comparing two independent groups on a continuous or ordinal measure, especially with a small sample, a skewed distribution, marked outliers, or ordinal-scale data.
  • If two measurements on the same people are compared, use the Wilcoxon signed-rank test; with three or more independent groups, use the Kruskal-Wallis test.
  • If the groups' spreads clearly differ, the Brunner-Munzel test, which does not require equal variances, is an option; if the data are near-normal and the sample large enough, the independent-samples t-test is more powerful.

An everyday example

A provincial health directorate compares how long patients wait before being seen in the emergency departments of two hospitals, with records for 14 patients from hospital A and 12 from hospital B. Waits are mostly 20-60 minutes, but two patients at B waited more than 3 hours. Because these extreme values would inflate the mean, the Mann-Whitney U test is used: all 26 patients are ranked by waiting time and the two hospitals' ranks are compared. If hospital B's mean rank is clearly higher and p = 0.02, patients at B can be said to wait longer in general; and the two 3-hour waits alone do not drive the result.

Parameters in MerQur

Confidence Level (%90, %95, %99, Other (custom), 80.0-99.9)

Concept: The confidence level sets how 'sure' the intervals for the location shift and the effect size are, and the threshold (α) for significance decisions. It does not change the U statistic or the p value.

Everyday example: With 95% confidence, waits at hospital B might be given as typically 'between 4 and 25 minutes' longer than at A. Asking for 99% confidence widens the interval.

What it does: α = 1 - confidence level; the HL location shift CI, the rank-biserial CI, the exact HL CI, and the decision use this α.

Effect on the result: U and p do not change. The HL asymptotic CI is computed by inverting the test: CI = {d : the W(d) test does not reject}; σ(d) is tie-corrected and ties are recounted for each d. The custom value is valid only when "Other" is selected.

On the validation data: diffusion 90% [-0.08, 0.72], 95% [-0.15, 0.76], 99% [-0.38, 1.01]. React 98% lower limit -0.82.

→ Confidence level and confidence interval

Hypothesis direction (Two-sided (≠), Right-tailed (>), Left-tailed (<))

Concept: The direction of the hypothesis states whether the question concerns any difference or only a tendency for one group's values to be larger (or smaller). 'Larger' here is meant in a stochastic sense: not the mean, but the tendency for the first group's value to come out larger in a random pair.

Everyday example: If, before a new system is installed at hospital B, the directorate asks only 'are waits longer at B?', the test is one-sided. If it is unknown which hospital is faster, a two-sided test is chosen.

What it does: H₀: the two distributions are the same (stochastic equality: P(X > Y) = P(Y > X)). H1: the first group is stochastically larger (>), smaller (<), or different (≠).

Effect on the result: p changes.

On the validation data: diffusion (no ties, automatic = exact) two-sided p = 0.254412, right-tailed 0.127206, left-tailed 0.896770. React asymptotic, continuity off, left-tailed p = 0.038201.

→ One-sided and two-sided tests (hypothesis direction)

Computation method (Auto, Exact, Asymptotic)

Concept: In small samples, the distribution of U under the null hypothesis can be computed exactly from all possible rank arrangements. As the sample grows, this distribution approaches the normal and the p value is found by a normal approximation. With equal values (ties), the exact distribution changes; a tie-corrected approximation or a conditional exact calculation is then needed.

Everyday example: With only 6 patients per hospital, the exact p value would be easy to compute. With 14 and 12 patients the normal approximation is usually adequate; because waits are rounded to the minute, a few patients waiting the same time create ties.

What it does: Automatic: the exact U distribution if one group has n <= 8 and there are no ties, otherwise the normal approximation; Exact: the exact U distribution without ties, the conditional exact permutation with ties (a warning is written); Asymptotic: the tie-corrected normal approximation.

Effect on the result: p changes.

On the validation data: React Exact p = 0.105411, Asymptotic with continuity on 0.084254, off 0.076402. rotarod Exact 0.037267.

→ Exact test and exact p-value

Extra output: Continuity correction (default on)

Concept: U is a discrete statistic that takes only whole-number values; when it is approximated by the continuous normal distribution, a half-unit shift (the continuity correction) improves the approximation. The correction makes the p value slightly larger, so the test slightly more cautious; its effect vanishes as the sample grows.

Everyday example: With 26 patients, the continuity correction might raise p from 0.018 to 0.020, for example. If the result is borderline this small difference can affect the decision, so the option used should be reported.

What it does: Turns the continuity correction on or off in the asymptotic p.

Effect on the result: No effect in the exact method (diffusion 0.254412 in both).

On the validation data: React asymptotic 0.084254 (on) and 0.076402 (off); hsb2 0.000875 (on).

→ Continuity correction (Yates)

Effect sizes: CLES (checkbox)

Concept: The common-language effect size (CLES): the probability that a randomly chosen member of the first group has a larger value than a randomly chosen member of the second, with ties counted as half. 50% means no difference.

Everyday example: One patient is chosen at random from A and one from B, and their waits are compared. If CLES = 0.23, the patient at A waited longer in only 23% of such comparisons; in most comparisons the patient at B waits longer.

What it does: P(X > Y) + ½P(X = Y), X = first group.

Effect on the result: Adds only an extra effect size row; the test result does not change.

On the validation data: diffusion 0.7, rotarod 0.7083, hsb2 0.3635.

→ Common-language effect size (CLES)

Effect sizes: Z / √N (checkbox)

Concept: The r obtained by dividing the test's standard normal value Z by the square root of the total sample size gives the size of the difference on a 0-to-1 scale. Roughly, 0.1 is read as a small, 0.3 a medium and 0.5 a large effect.

Everyday example: With Z = 2.3 and 26 patients, r = 2.3/√26 ≈ 0.45, a medium-to-large difference between the two hospitals.

What it does: The effect size derived from Z, r = Z/√N.

Effect on the result: Adds only an extra effect size row.

On the validation data: diffusion Z = 1.225, r = 0.3162; rotarod Z = 2.439.

→ r effect size from Z/√N

Extra output: Descriptive (checkbox)

Concept: Gives each group's summary: count, mean, standard deviation, standard error, median, minimum and maximum, skewness and kurtosis. Before a rank-based test, it shows why the data are skewed and where the extreme values lie.

Everyday example: The table shows a mean of 68 and a median of 50 minutes for hospital B; the gap shows that a few very long waits pull the mean up. At A the mean and median are close.

What it does: n, mean, SD, SE, median, minimum, maximum, skewness, kurtosis per group.

Effect on the result: Adds only a descriptive table.

On the validation data: Skewness and kurtosis are given with the sample-adjusted (G1, G2) definition. In the rotarod control group (SD = 0), skewness and kurtosis are undefined.

Permutation p (None, Exact (conditional permutation), Monte Carlo (B = 10000))

Concept: The permutation p value generates the null distribution of U from the data by randomly reassigning the group labels; even with ties it gives a p that does not rely on the normal approximation. The exact calculation tries all arrangements, the Monte Carlo version thousands of random ones.

Everyday example: The 26 patients' waiting times are kept fixed while the 'A' and 'B' labels are shuffled at random and U is recomputed each time. The share of values as extreme as the observed U gives a p that is not affected by tied waiting times.

What it does: Adds a conditional exact or Monte Carlo permutation p.

Effect on the result: Extra p row only.

On the validation data: Exact conditional p: React 0.1054106, rotarod 0.0372671, hsb2 0.000809. Monte Carlo (B = 10000, seed 12345): React 0.1125, diffusion 0.2563; within 4 MC SD of the exact values.

→ Permutation p-value

Extra outputs: Rank-biserial CI (checkbox)

Concept: The rank-biserial correlation is a widely used effect size for the Mann-Whitney test: the difference between the share of pairs in which the first group is 'ahead' and the share in which it is 'behind'; it ranges from −1 to 1. Its confidence interval shows how precisely this effect is estimated.

Everyday example: If r_rb = 0.54, pairs in which the patient at B waited longer than the patient at A occur 54 percentage points more often than the reverse. If the confidence interval is [0.15, 0.79], the effect may be small or large; 26 patients are too few for a firm verdict.

What it does: Fisher z CI for r_rb = 1 - 2U/(n1n2) (SE = √((N + 1)/(3n1n2))).

Effect on the result: Adds a confidence interval to the rank-biserial r.

On the validation data: diffusion r = -0.4000, 95% CI [-0.7871, 0.2132]; sign convention: r is positive if the first group tends to have smaller values. r = 1 - 2U₁/(n₁n₂); the first group is the level that appears first in the data; this sign convention is the reverse of effectsize::rank_biserial and of the Kerby (2014) convention.

→ Rank-biserial correlation

Extra outputs: Brunner-Munzel (checkbox)

Concept: The Brunner-Munzel test asks the same question as the Mann-Whitney test (is the probability that one group's value exceeds the other's 50%?) but does not assume that the two groups have the same distribution shape and spread. When the groups differ greatly in spread, the Mann-Whitney test's false-alarm rate can be distorted; Brunner-Munzel is more reliable in that case.

Everyday example: If waits at hospital A cluster between 30 and 45 minutes while those at B range from 10 minutes to 3 hours, the two distributions have very different shapes. Brunner-Munzel correctly tests the probability that a patient at B waits longer, despite this difference.

What it does: Adds the Brunner-Munzel test, which does not require equal variances, and the estimate p̂ = P(X < Y) + ½P(X = Y).

Effect on the result: Adds an extra test section; the Mann-Whitney result does not change.

On the validation data: diffusion W = -1.4103, p = 0.184636, p̂ = 0.30; React W = 2.3416, p = 0.031798; rotarod (control variance 0) W = -2.8031, p = 0.017180.

→ Brunner-Munzel test

Extra outputs: KS, Wald-Wolfowitz, Moses (checkbox)

Concept: These tests look at different aspects of two distributions. The two-sample Kolmogorov-Smirnov test measures the largest gap between the cumulative distributions and is sensitive to any difference in location, spread or shape. The Wald-Wolfowitz runs test looks at how well the two groups mix in the sorted data. The Moses test of extreme reactions checks whether one group is concentrated at the extremes, at very low and very high values.

Everyday example: If at hospital B some patients are seen very quickly and others wait very long, with few in between, the two hospitals' distributions differ even if their medians are similar. The Moses test may detect that B is concentrated at the extremes, and Kolmogorov-Smirnov that the two distributions differ overall.

What it does: Adds the two-sample Kolmogorov-Smirnov, Wald-Wolfowitz runs, and Moses extreme reactions tests.

Effect on the result: Adds extra test sections; the Mann-Whitney result does not change.

On the validation data: KS: diffusion D = 0.6, p = 0.181300; Arthritis D = 0.4051, asymptotic p = 0.016358. Wald-Wolfowitz: diffusion runs = 7, exact p = 0.454545. Moses: diffusion span = 12, p = 0.846154.

→ Kolmogorov-Smirnov test and Lilliefors correction

Extra outputs: Exact HL CI (checkbox)

Concept: The Hodges-Lehmann location shift is the median of the differences over all possible pairs of observations from the two groups; it estimates how far one group is 'typically shifted' relative to the other. The exact confidence interval finds the range of this estimate from the exact distribution of U instead of an approximate formula; it is more accurate in small samples without ties.

Everyday example: With 14 patients from A and 12 from B, there are 168 different 'B − A' pairs. If the median of these differences is 14 minutes, waits at B are typically 14 minutes longer; the exact interval shows the uncertainty of this value.

What it does: The exact confidence interval for the Hodges-Lehmann location shift.

Effect on the result: Adds an exact CI row for untied data; with tied data it is not computed and an information row is written.

On the validation data: diffusion 95% [-0.15, 0.76], 98% [-0.17, 0.90], 99% [-0.35, 1.01] (from the exact distribution; the asymptotic 99% CI is [-0.38, 1.01]).

→ Hodges-Lehmann estimator (pseudomedian)

Score / scale tests: Van der Waerden + Savage; Scale tests (Siegel-Tukey, Ansari-Bradley, Mood, Klotz, Fligner-Killeen) (checkboxes)

Concept: Instead of the ranks themselves, other scores derived from the ranks can be used. The Van der Waerden test converts ranks to normal scores and is as powerful as the t-test when the data are near-normal; the Savage test is powerful for exponential-type data such as lifetimes or waiting times. The scale tests (Siegel-Tukey, Ansari-Bradley, Mood, Klotz, Fligner-Killeen) test not location but whether the groups' spreads differ.

Everyday example: If the directorate suspects that hospital B is more 'unpredictable', with waits spread over a wider range, it looks at the scale tests. If Ansari-Bradley or Fligner-Killeen is significant, the spread of waiting times differs between the two hospitals.

What it does: Location (VW, Savage) and scale (Siegel-Tukey, Ansari-Bradley, Mood, Klotz) tests with score definitions that use the mean score for ties; Fligner-Killeen separately. S, Z, and the two-sided p are given with the normal approximation.

Effect on the result: Added as an extra section at the end of the Mann-Whitney output.

On the validation data: For warpbreaks (wool), S, Z, and p are given (Z: VW -0.5355321715, Savage -1.4448256386, Ansari-Bradley 2.7202941017, Mood -2.9963036151, Klotz -2.7714392386).

→ Score and scale tests (Van der Waerden, Savage, Siegel-Tukey, Ansari-Bradley, Mood, Klotz)

Always shown outputs

Concept: The core results are given together on every run: the U statistic, the p value, the rank-biserial effect size, the Hodges-Lehmann shift estimate and its confidence interval, and each group's count, median, mean rank and rank sum. The mean ranks are the summary that most directly shows what the test looks at.

Everyday example: If hospital A's mean rank is 10.3 and B's is 17.3, patients at B generally sit further back in the ranking, meaning they wait longer. With U, p, r_rb and the Hodges-Lehmann shift reported together, readers see both the decision and the size of the difference.

What it does: U (U of the first group), p, rank-biserial r and its label, HL estimate and CI, group n / median / mean rank / rank sum.

Effect on the result: Written in every run regardless of the options; the effect size label uses r thresholds (.1 / .3 / .5).

On the validation data: The rank sums and mean ranks are given for React, Arthritis, and hsb2 (React 110.5 and 79.5; 8.5 and 13.25). diffusion |r| = 0.40 "Medium".

Example on real data

Data: UCLA OARC hsb2 (High School and Beyond, n = 200)

Variables: group female (0 = male, 1 = female), value write (writing score)

  • Question: Does the writing score (write) differ between male and female students? The rank-based Mann-Whitney U test, which does not require normality, is used.
  • Descriptive: Males (n = 91) have median 52 and mean rank 85.63; females (n = 109) have median 57 and mean rank 112.92.
  • Result: U = 3606, p = 0.000875 (continuity-corrected normal approximation). The null hypothesis is rejected: the writing scores of females are stochastically higher.
  • Effect size: Rank-biserial r = 0.27 (small effect); Hodges-Lehmann location shift -5.0 points, 95% CI [-8.0, -2.0].
  • Limitation: Because there are many tied ranks, p is computed with the normal approximation; with the continuity correction on, Z and p differ slightly from the uncorrected values.
  • APA: U = 3606.00, p < .001, r = .27.

Related concepts

Common-language effect size (CLES)Kolmogorov-Smirnov test and Lilliefors correctionAsymptotic (normal) approximationHodges-Lehmann estimator (pseudomedian)Rank-biserial correlationBrunner-Munzel testScore and scale tests (Van der Waerden, Savage, Siegel-Tukey, Ansari-Bradley, Mood, Klotz)r effect size from Z/√N

The numbers in the examples are MerQur's output on independent, publicly available validation data; see the MerQur Technical Note for details.