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

Did the Service Change Land?

Capstone 15. Seventy customers rated the service twice, before and after a change to the booking process. Forty-four percent gave the identical rating both times, and what you do with those people turns out to be the whole methodological question.

โฑ๏ธ ~16 min read
๐Ÿงช Wilcoxon signed-rank
๐Ÿ“Š Chapter 174

Capstone 3 ran a paired t-test on blood pressure, where the differences were continuous and comfortably normal. This is the same design on a 5-point rating scale, and almost nothing survives the change: the differences take four values, nearly half of them zero, and the exact test is off the table before we start.

The brief
Setting
The same customers rated a service on a 5-point scale before a booking change and again afterward, leaving 70 complete pairs once the file was cleaned.
The question
Did ratings improve after the booking change?
Why it matters
The company is deciding whether the change earned its cost and whether to extend it. A shift of a fraction of a point on a 5-point scale can be decisive statistically and still be modest in practice.
What we do
Run the Wilcoxon signed-rank test on the paired differences, confront the zero-difference convention that most software applies silently, explain why no exact p-value is available here, and report the result as proportions with margins.
W
The Wilcoxon signed-rank test is the paired counterpart of Mann-Whitney. It ranks the differences by size, ignoring direction, then compares the total rank belonging to increases against the total belonging to decreases. It assumes nothing about the shape of the differences.
โญ
The finding, up front

Ratings improved, decisively (W = 343, p = 0.000048, n = 70), with a large effect (rank-biserial 0.68). The practical picture is more modest: 46 percent of customers rated higher, 44 percent did not move at all, and 10 percent rated lower. The median went from 3 to 4, which is one step on a five-step scale.

1

A Paired Design on an Ordinal Scale

The same customers rated the service before the booking change and again afterwards. Because each row is one person measured twice, the two columns are not independent samples and the analysis works on the differences. That much matches Capstone 3. What does not match is the measurement.

Ratings are ordinal on five points, so a difference can in principle be anything from −4 to +4. In this data it takes four values: −1, 0, +1, and +2. That coarseness is not a flaw in the sample. It is what a 5-point scale produces, and it drives every methodological choice that follows.

Cleaning removed two duplicate submissions, three customers who never answered the follow-up, and one impossible rating of 0, leaving 70 paired customers.

The three who vanished

Three customers rated the service before the change and never answered the second survey. A paired test needs both halves, so they are dropped. But they are not a random three: someone who has given up on a service is exactly the person who stops replying to its surveys. If all three would have rated lower, the estimate here is flattering. That is a limitation to state, not to fix.

2

What Moved, and What Did Not

Left: grouped bars of ratings 1 to 5 before and after. The counts at 3 and 4 fall while the count at 5 rises from 4 customers to 21. Right: a bar chart of the change in rating showing 7 customers at minus 1, 31 at zero in gray, 28 at plus 1, and 4 at plus 2.
Left: ratings shifted upward, and mostly at the top, with the number of customers giving the maximum rating going from 4 to 21. Right: the change per customer. The gray bar is the story of this chapter: 31 of 70 customers gave exactly the same rating twice.

Twenty-eight customers went up by one, four went up by two, and seven went down by one. Nobody moved more than two points, which is the ceiling the instrument imposes.

3

Why Not a Paired t-test

A paired t-test assumes the differences are approximately normal. Shapiro-Wilk on these differences gives W = 0.848, p = 0.0000006, but the p-value understates the problem. The differences take four distinct values, 44 percent of them identical at zero.

This one is not fixable by transformation

Earlier capstones met skewed data that a log or a square root could tidy up. Nothing does that here, because the problem is not the shape of a continuous distribution. It is the granularity of the measurement. Four possible outcomes will still be four possible outcomes after any transformation you apply to them.

Wilcoxon's signed-rank test ranks the differences by size and compares the rank total for increases against the rank total for decreases. Nothing about equal spacing is assumed, which suits a rating scale exactly.

4

The Zeros, and the Decision Nobody Mentions

Thirty-one customers changed nothing. A signed-rank test has no natural slot for them: a difference of zero is neither an increase nor a decrease, and it has no size to rank. Every implementation has to decide something, and most do it silently through a default argument.

A five by five grid of before rating against after rating, with counts in each cell and a dashed diagonal line. Cells on the diagonal, meaning no change, hold 31 customers in total. Most of the off-diagonal mass sits just above the diagonal.
Where each customer moved. Everyone on the dashed line gave the identical rating twice, and there are 31 of them, more than any other single feature of this dataset. The three conventions below disagree about exactly one thing: what to do with that line.
ConventionWhat it does with the zerosn usedWp
Wilcoxon (1945)discards them entirely39126.00.000050
Pratt (1959)ranks them, then drops their ranks70343.00.000048
Split ranksdivides the zero ranks between both sums70591.00.000090

They agree here, and that is worth saying plainly. All three land within a factor of two of each other and all three reject the null decisively. This dataset does not force the choice, and it would be dishonest to imply otherwise.

Understand it anyway, because it changes the question

Wilcoxon's original procedure discards the 31 non-movers and tests the 39 who moved, so it answers: among customers whose opinion changed, did it more often improve? Pratt's method keeps them, so it answers: across all customers, did ratings improve? Those are different claims about different populations. With 44 percent of the sample sitting on zero, the second is the one a service manager is asking, which is why it is the one reported here. Whichever you use, state it and state the n it consumed. A reader who sees "n = 39" and a reader who sees "n = 70" are being told about different groups of people.

5

The Result

Wilcoxon W (Pratt)
343.0
n = 70
p-value
< 0.001
4.8 × 10−5
Rank-biserial r
0.677
large effect
Sign test
p = 0.00007
direction only, agrees

Among the 39 customers who moved, the rank total for the 32 improvements is 654 against 126 for the 7 declines. The rank-biserial correlation of 0.68 is that imbalance expressed on a scale from −1 to +1.

The sign test is a useful cross-check. It throws away even the sizes of the changes and looks only at direction, so it assumes less than Wilcoxon does and has less power in exchange. It still rejects at p = 0.00007. When the weakest test available agrees, the conclusion is not resting on an assumption.

THREE TESTS OF THE SAME PAIRED DATA, ASSUMING LESS AT EACH STEP Paired t-test uses the exact size of every difference needs normal differences not available here Wilcoxon signed-rank uses the ORDER of the difference sizes needs only symmetry p = 0.000048 ← reported Sign test uses only the DIRECTION: up, down, or neither needs almost nothing p = 0.00007 agrees each step discards information in exchange for a weaker assumption
The ladder of assumptions. Moving right, each test uses less of the data and demands less of it. The usual worry is that the weaker tests will miss a real effect. Here they do not, which is the most reassuring thing a set of results can do.
6

Why There Is No Exact p-value

Textbook examples of Wilcoxon usually quote an exact p-value computed by enumerating every possible arrangement of signs. This one cannot, and the reason is structural rather than a matter of software settings.

On a 5-point scale, a change is one point or two points. Across the 39 customers who moved, there are exactly two distinct magnitudes: 35 changes of size 1 and 4 of size 2. The signed-rank procedure ranks by magnitude, so those 35 changes all receive the same average rank, as do the 4.

What the software does, and why it is right

The exact permutation distribution assumes there are no ties, so it does not apply. scipy detects the ties, assigns average ranks within each tied block, and switches to the normal approximation with a tie correction. That is the correct behavior. It is worth recognizing that it happened, rather than assuming an exact test was simply not requested, because on coarse scales the tie correction is doing real work.

7

Statistically Decisive, Practically Modest

The p-value establishes that ratings moved up. It says nothing about whether the movement justifies what the change cost, and those two questions get confused constantly.

SummaryValue
Median rating3 before, 4 after: one step on a five-step scale
Rated the service higher32 of 70 customers (46%)
Did not change their answer31 of 70 customers (44%)
Rated the service lower7 of 70 customers (10%)
Gave a top-two rating (4 or 5)29 before (41%) → 39 after (56%)

The top-two-box figure, 41 percent rising to 56 percent, is probably the number to put in front of a business, because it corresponds to something an operations team recognizes and it does not require anyone to average an ordinal scale. But the sentence that goes with it should mention the 44 percent who did not move and the 10 percent who moved the wrong way. A statistically decisive result and a modest practical one are perfectly compatible, and this is what that looks like.

8

What to Watch

9

Paired Rank Tests in Data Science & AI

The before-and-after comparison on the same units is one of the most common shapes in applied work, and the zeros problem travels with it everywhere.

Where it appearsThe paired measurement
Model A versus model B on a shared benchmarkThe same test items scored under two systems, which is the classic paired setup.
Human evaluation of two outputsThe same rater scoring both, on an ordered scale, with plenty of ties.
Before and after a deployThe same users, sessions, or queries measured across a release.
Feature-flag rollouts to the same cohortEach unit acts as its own control, which removes between-user variation.
Practice note

Benchmark comparisons between two models are almost always paired, since both are evaluated on the same items, and paired analysis is far more sensitive than treating the two score sets as independent samples. It is also where the zeros problem is most acute: on many benchmarks the two models agree on the majority of items, so the reported n can be a small fraction of the benchmark size. A comparison quoting "p < 0.01" over 800 items, when 760 of them were ties, is describing 40 items. That should be stated, not buried in a default argument.

10

Estimate: Proportions With Margins

The test established that ratings rose. The operations question is what share of customers moved, and every one of those shares is a proportion estimated from 70 people.

QuantityEstimate95% CI (Wilson)
Rated the service higher46%35% to 57%
Did not change their answer44%33% to 56%
Rated the service lower10%5% to 19%
Top-two-box before41%31% to 53%
Top-two-box after56%44% to 67%
Matched-pairs rank-biserial0.6770.438 to 0.879 (bootstrap)
Do not compare those last two intervals

The top-two-box share rose from 41 to 56 percent, and the two intervals overlap heavily. It would be a mistake to conclude from that overlap that the change is unclear, because the same people are measured twice, so the two estimates are not independent. The paired count is the right one: 13 customers moved into the top two boxes and 3 moved out, which on its own terms gives p = 0.02.

That is the same paired-versus-independent distinction the whole chapter rests on, applied to proportions instead of ratings. Treating before and after as two separate samples throws away the pairing and most of the precision it bought.

SAME DATA, TWO READINGS: ONLY ONE RESPECTS THE PAIRING TREATED AS TWO SAMPLES TREATED AS PAIRS before 41% after 56% the intervals overlap... "we cannot tell" — wrong these are the same 70 people twice 13 moved IN 3 moved OUT the other 54 customers never crossed the line, so they carry no information about change 13 against 3 gives p = 0.02
Overlapping intervals are not a verdict when the samples are the same people. The paired view discards the 54 customers who never crossed the top-two-box line, because only the switchers carry information about change, and compares the 13 who moved up against the 3 who moved down.

One more column the analysis had not opened. The file records visits_per_month. Frequent visitors experience a booking change far more often than occasional ones, so it is a natural place to look for a difference, and there is not one: visit frequency shows no detectable relationship with how much a rating moved (ρ = 0.09, p = 0.44), and splitting at the median gives two groups that improved similarly. That is mildly reassuring, since a change registering only with people who book weekly would be a narrower win than the headline suggests. It does nothing about the missing control group, because whatever else changed during those months affected frequent and occasional visitors alike and would leave exactly this trace. Checking a covariate you happen to have is not the same as having a comparison group.

๐Ÿ

The full project, step by step

The companion notebook cleans the paired records with a printed audit trail, plots the before-and-after ratings and the distribution of changes, checks the assumption a paired t-test would need and explains why no transformation rescues it, draws the transition matrix that makes the zeros unmissable, then runs all three zero conventions side by side. It computes the effect size, cross-checks with the sign test, shows why the exact test is unavailable, and closes with the practical summary.

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

The dataset (capstone-service-ratings-before-after.xlsx) holds the paired ratings with duplicates, follow-up non-responses, and an impossible rating left in so you can practice the cleaning. Two written reports accompany it: a plain-language brief for an operations lead, and a technical report covering the zero conventions, the tie structure, and the effect size.

๐ŸŽ“ Key Takeaways

  • โœ“Wilcoxon is the paired rank test: it ranks differences by size and compares the rank total for increases against the total for decreases.
  • โœ“Zeros are a decision, not a detail. Dropping them tests the 39 who moved; keeping them tests all 70. Different questions, different populations, so state which and state the n.
  • โœ“Coarse scales kill the exact test. With only two distinct change magnitudes, the ranks are heavily tied and the normal approximation with a tie correction is the correct fallback.
  • โœ“The sign test is the honest cross-check. It assumes almost nothing and still rejected (p = 0.00007), so the conclusion does not depend on the extra assumption Wilcoxon makes.
  • โœ“Decisive is not the same as large. p = 0.000048, and yet 44% of customers did not move at all and 10% moved the wrong way.
11

Quiz: Test Yourself

Eight questions on this capstone, from the zeros problem to what a decisive p-value does not tell you. Answer them, hit Check Answers, and keep refining until you score 100%. Your progress is saved.