Contents/ Part XXVII · Capstone Projects: Statistical Testing/ Chapter 173

Which Painkiller Actually Helps?

Capstone 14. Two treatments, ninety-one patients, and relief scored out of ten by the people feeling it. The two distributions are shaped nothing alike, which changes not only the test but the sentence you are allowed to write at the end.

โฑ๏ธ ~18 min read
๐Ÿงช Mann-Whitney U
๐Ÿ“Š Chapter 173

This is the first capstone where the parametric assumptions fail outright, and the first where the choice of test changes what you may claim, not just how you compute it. Mann-Whitney is usually introduced as the fallback when normality breaks. That undersells it, and this trial shows why.

The brief
Setting
A trial recorded patient-reported relief on an 11-point numeric rating scale for two treatment arms, New and Standard.
The question
Does the new treatment produce more relief than the standard one?
Why it matters
A prescribing recommendation follows from the answer, and it has to be stated in something a patient and a prescriber can both act on.
What we do
Show why the mean of an ordinal scale has no nameable unit, run the Mann-Whitney test as a comparison of whole distributions, report the probability of superiority and the Hodges-Lehmann shift, and check whether the two arms started level.
U
The Mann-Whitney U test compares two independent groups using only ranks. It asks whether values in one group tend to be larger than values in the other, a property called stochastic dominance. It assumes nothing about the shape of either distribution.
โญ
The finding, up front

The new analgesic beats the standard one decisively (U = 1557.5, p = 0.000028, n = 91). The effect size worth quoting is not a difference in points: pair any new-treatment patient with any standard-treatment patient and the new one does better about three times in four. But the benefit is not spread evenly, and the averages conceal that.

1

What "Relief" Actually Is

Patients reported relief on an 11-point numeric rating scale, 0 for none and 10 for complete. The number is genuinely ordered: 7 is more relief than 4. It is not a measurement in the way a blood pressure reading is.

WHAT THE NUMBERS IMPLY 0 1 2 3 4 5 6 7 8 9 10 WHAT PATIENTS MAY ACTUALLY MEAN 0 1 2 3 4 5 6 7 8 9 10
The scale is ordered, not measured. Nothing in the instrument establishes that going from 2 to 3 is the same amount of relief as going from 7 to 8. Patients cluster near the ends and stretch the middle, or the reverse, and no two patients need do it the same way. The ordering is real; the spacing is invented by the numbering.
Why that matters before any test is chosen

If the spacing is not established, then the mean of these scores is a number whose units nobody can name. "The new treatment produced 2.28 more points of average relief" reads like a measurement and is not one. The variable is ordinal and bounded at both ends, which by itself guarantees the data cannot be normal.

2

Two Very Different Pictures

Cleaning removed two duplicate records, two blanks, and one impossible score of 14 on an 11-point scale, and normalized the treatment labels, leaving 91 patients. Then, before any test, the plot.

Two bar charts of relief scores from 0 to 10. The Standard group shows one hump crowded at the low end, peaking at 1 with 16 patients and tailing off. The New group shows two separate clusters, one from 0 to 3 and a larger one from 5 to 8, with a near-empty gap at 4.
Counts of patients at each relief score, not a smoothed curve, because the scale has eleven possible answers. Standard is one hump crowded at the low end. New is two clusters with a near-empty gap at four: patients it barely touched, and patients it helped a great deal.

That difference in shape is not a nuisance to be handled. It is the most clinically interesting thing in the dataset, and it comes back in section 6.

3

The Assumptions, and the Better Reason to Use Ranks

CheckStandardNewVerdict
Shapiro-Wilk (normality)W = 0.830, p < 0.001W = 0.941, p = 0.024fails in both
Skew+1.71−0.09strongly right-skewed in one arm
Levene (equal spread)p = 0.006fails
Bartlett (equal spread)p = 0.044fails
Standard deviation1.942.631.36× more variable

Both parametric assumptions fail. It would be easy to stop there and call that the justification. It is the weaker argument, and here it is nearly beside the point: with 45 patients per arm, a t-test would tolerate this much skew reasonably well, and section 5 shows it reaches the same verdict.

The argument that actually holds

The reason to use ranks is what the outcome is, not what the diagnostics said. A rank test asks a question the scale can answer: are patients on this treatment reporting more relief than patients on that one? That question needs only the ordering, which the scale genuinely provides. A test built on means needs the spacing, which it does not.

4

The Result

Mann-Whitney U
1557.5
45 New vs 46 Standard
p-value
< 0.001
2.8 × 10−5
Probability of superiority
0.752
the number to quote
Rank-biserial r
0.505
large effect

There are 45 × 46 = 2,070 ways to pair one new-treatment patient with one standard-treatment patient. The new patient reported more relief in 70 percent of them and less in 20 percent, with the remaining 10 percent tied. Splitting the ties gives the headline figure: the probability of superiority is 0.75.

Left panel: two cumulative distribution curves. The New treatment's curve lies below the Standard's across the whole scale. Right panel: a horizontal stacked bar showing 70 percent of pairings favoring New in green, 10 percent tied in gray, and 20 percent favoring Standard in red.
Left: the cumulative curves. New sits at or below Standard everywhere, meaning that wherever you set a threshold, a smaller share of new-treatment patients fall under it. Right: all 2,070 head-to-head pairings, sorted into wins, ties and losses. This is what the effect size is counting.
5

It Is Not a Test of Medians

Mann-Whitney is routinely described as "the nonparametric test of medians". That description is wrong, and this trial is exactly the case where being wrong about it matters.

SAME SHAPE, SHIFTED DIFFERENT SHAPES a single shift "the median is 3 points higher" is meaningful non-responders responders no single shift exists only "New tends to be higher" is defensible
The condition nobody quotes. Mann-Whitney becomes a test of medians only when the two distributions have the same shape, so that one is a copy of the other slid along the axis. Then a single number describes the difference. When the shapes differ, as they plainly do here, no single shift exists to report, and the honest claim is the one about tendency.

So the defensible sentence for this trial is "in 75 percent of head-to-head pairings the new-treatment patient did better". Writing "the median relief was 3 points higher" would be smuggling in a shift model the data do not support. The medians are 5 and 2, and the difference between them is a real description of these two samples, but it is not what the test established.

6

The Finding Hiding Under the p-value

A t-test on this data gives t = 4.692, p = 0.000011. It agrees. Nothing here is a case of a parametric test being fooled, and it is worth saying so plainly rather than implying the rank test rescued the analysis. What it did was let us describe the result in terms the measurement supports.

Both tests, though, answer the question that was asked rather than the more useful one. Look at what the summary statistics average over.

OutcomeStandard (n = 46)New (n = 45)
Reported 4 or more points of relief9 patients (20%)28 patients (62%)
Reported almost none (0 or 1)19 patients (41%)6 patients (13%)
Median relief25
Mean relief2.394.67

The new treatment does not lift everyone by a couple of points. It splits patients into a group it helps substantially and a group it barely touches. A single summary number, mean or median, describes an average patient who does not appear in this trial. The obvious follow-up is what distinguishes the responders, and that is a question for the baseline data and a fresh study, not for another test on this outcome.

7

What to Watch, and What Not to Promise

8

Rank Tests in Data Science & AI

Bounded, skewed, self-reported outcomes are the norm rather than the exception outside the textbook, and the probability of superiority travels well beyond clinical work.

Where it appearsWhy ranks fit
Latency and load-time A/B testsResponse times are hard-floored at zero and heavily right-skewed; the mean is dominated by a long tail.
Model output preference studiesHuman ratings of two systems on an ordered quality scale, exactly this design.
Revenue and engagement per userA handful of extreme users otherwise drive the entire comparison.
Benchmark score comparisonsBounded metrics that pile up near a ceiling break the equal-spacing assumption.
Practice note

The probability of superiority is the effect size to reach for whenever a stakeholder has to act on the result. "Version B is faster for 68 percent of requests" lands where "the mean latency fell by 41 milliseconds" does not, and on a skewed distribution the second number can be driven almost entirely by the tail. The same caution applies as in the trial above: it is a statement about pairings, not about the share of users who will be better off.

9

Estimate, and Check the Arms Started Level

The headline effect size, a probability of superiority of 0.75, is a point estimate from 91 patients. It deserves an interval as much as any mean does, and the bootstrap supplies one without needing a formula.

QuantityEstimate95% CI (bootstrap)
Probability of superiority0.7520.648 to 0.845
Rank-biserial correlation0.5050.296 to 0.690
Hodges-Lehmann shift+2.0 points+1.0 to +4.0
New arm reaching 4+ points relief62%48% to 75% (Wilson)
Standard arm reaching 4+ points20%11% to 33% (Wilson)

Even the pessimistic end of the superiority interval is a substantial advantage, which is what makes the finding solid. The honest phrasing for a clinician is "around three times in four, and certainly better than two in three". The responder proportions carry margins too, and they are what a formulary committee will actually use: 62 percent give or take roughly 14 points is what a 45-patient arm can establish.

This check did not pass, and that is worth sitting with

The file records baseline pain for every patient, which the analysis had not used. In a randomized trial this is the first table of the paper. Here the new-treatment arm started in more pain than the standard arm, 7.31 against 6.70, and the difference is larger than chance comfortably explains (p = 0.011). Randomization balances groups in expectation, not in every particular trial, and with 91 patients a visible imbalance on some variable is far from rare. This is one.

The direction is the unhelpful one. Patients who start in more pain have more room to improve, so an arm that begins worse can look better on a change score for reasons unrelated to the drug. That is regression to the mean, the mechanism that haunted Capstone 3, arriving here through the back door of an unlucky allocation.

Two things stop it overturning the result. Baseline pain barely relates to reported relief in this trial (ρ = 0.08, p = 0.43), so the mechanism that would translate the imbalance into a spurious effect is weak. And the effect itself is large; a 0.6-point head start on an 11-point scale is not going to manufacture a probability of superiority of 0.75. What it changes is the write-up. A trial report that omits this table is hiding something a reader would want. The honest version states the imbalance, states why it is unlikely to explain the finding, and pre-specifies a baseline-adjusted analysis for the confirmatory study. Reporting a randomized trial is not the same as reporting that randomization worked.

๐Ÿ

The full project, step by step

The companion notebook cleans the trial records with a printed audit trail, plots both distributions before touching a test, runs the normality and equal-spread checks and records what they said, then computes U along with all 2,070 pairwise comparisons behind the effect size. It draws the cumulative curves that make stochastic dominance visible, contrasts a Welch t-test, and closes on the responder split the averages hide.

๐Ÿ““ View Notebook (code & outputs) โ–ถ Open in Colab โฌ‡ View / Download on GitHub
Read the reports & get the data

The dataset (capstone-pain-relief-two-treatments.xlsx) holds the trial records with duplicates, blanks, an out-of-range score, and inconsistent treatment labels left in so you can practice the cleaning. Two written reports accompany it: a plain-language brief for a clinical lead, and a technical report covering the dominance argument, the effect size, and the responder structure.

๐ŸŽ“ Key Takeaways

  • โœ“Mann-Whitney tests stochastic dominance, whether one group's values tend to be larger, not whether two medians differ.
  • โœ“It becomes a test of medians only if the two distributions share a shape. Here one is skewed and one is bimodal, so no single shift exists to report.
  • โœ“Quote the probability of superiority (0.75): a randomly paired new-treatment patient does better three times in four. It is a claim the ordinal scale supports.
  • โœ“The stronger case for ranks is measurement, not diagnostics. The t-test agreed (p = 0.000011); what it could not do was report a difference in units anyone can name.
  • โœ“Look past the summary. 62% of new-treatment patients cleared four points against 20% on standard, but 13% got essentially nothing. The average patient does not exist here.
10

Quiz: Test Yourself

Eight questions on this capstone, from ordinal measurement to what a rank test may and may not claim. Answer them, hit Check Answers, and keep refining until you score 100%. Your progress is saved.