The Wilcoxon signed-rank test answers one question: when the same people are measured twice, did their scores tend to go up or down? This guide explains how it works in plain language, how it is calculated, and how to run it in AnalyZ Solutions.
The Wilcoxon signed-rank test answers a simple question: when the same people are measured twice, did their scores tend to go up or down?
Suppose 25 patients rate their pain from 0 (none) to 10 (worst) before a treatment and again afterwards. Most ratings look lower the second time. Is that a real change, or could it have happened by chance? The test gives you a way to tell.
The usual way to check a change like this is to work out each person's change and test whether the average change differs from zero. The standard test for that is the paired t-test. It works well when the changes spread evenly around their average in a roughly bell-shaped pattern. It works badly in three common situations.
The test works out each person's change, sets aside for a moment whether it was up or down, and ranks the changes by size. The smallest change gets position 1, the next smallest position 2, and so on. Then it puts the direction back, adding up the positions of the increases on one side and the decreases on the other. If the treatment made no difference, the two sides would be about equal. If most of the big changes go the same way, they are not. A very large change is only the last position, so it cannot dominate. For background on this whole family of tests, see What are non-parametric tests?
Suppose 25 patients rate their pain from 0 to 10 before and after a treatment. You want to know three things. Did the ratings tend to change? In which direction? And how consistently did patients move the same way? The Wilcoxon signed-rank test answers all three.
Use it when each person is measured twice, or when people are matched in pairs, and at least one of these is true:
Examples include a pain or wellbeing rating before and after a treatment, a knowledge test taken by a small pilot group, and a confidence score recorded at the start and end of a workshop.
When the changes spread evenly around their average and the sample is moderate, the paired t-test is the standard choice. For two separate groups, use the Mann-Whitney U test. For three or more measurements on the same people, use the Friedman test. For help choosing between this test and the t-test, see What are non-parametric tests?
Three ideas make the test work: looking at the change for each person, ranking the sizes of the changes, and comparing increases with decreases.
For each person, subtract the first measurement from the second. A pain rating of 7 before and 4 after gives a change of -3. A person whose two values are identical has a change of zero, which says nothing about direction, so that person drops out.
A rank is a position number. Set the direction aside and line up the sizes of the changes from smallest to largest, numbering them 1, 2, 3 and so on. If two sizes are equal, they share the average of their positions. Then give each position its sign back: plus if the person's score rose, minus if it fell. If the treatment made no difference, the plus and minus positions would balance. If most of the big changes go one way, they do not.
The median is the middle value, so half the changes are above it and half below. The test reports the median of the changes. It is the typical change per person, and the number to quote when you describe how much scores moved.
The calculation has four steps. The formulas are there for readers who want to check the arithmetic, and the worked example below follows every step with real numbers.
If the measurements made no difference, increases and decreases would be equally likely. The positions add up to a total of n × (n + 1) ÷ 2, where n is the number of pairs left after the no-change pairs are dropped, and each side would collect about half of it. A W far below that expected half means the changes lean one way.
For larger samples, W is converted into a z value, which says how many standard errors W sits from the value expected if nothing had changed. The standard error measures how much W would vary from sample to sample by luck alone. The p-value then comes from the normal curve, the familiar bell shape. The p-value is the chance of seeing a pattern this lopsided by luck alone if the measurements really made no difference.
The effect size r is the difference between the two sums divided by their total. It runs from 0, when increases and decreases balance, to 1, when every change points the same way.
Eight patients rate their pain from 0 to 10 before and after a treatment.
| Pair | Before | After | Difference (after - before) | Rank of the size | Sign |
|---|---|---|---|---|---|
| 1 | 7 | 1 | -6 | 6 | - |
| 2 | 6 | 4 | -2 | 2 | - |
| 3 | 8 | 4 | -4 | 4 | - |
| 4 | 5 | 4 | -1 | 1 | - |
| 5 | 6 | 6 | 0 | dropped | |
| 6 | 7 | 4 | -3 | 3 | - |
| 7 | 9 | 4 | -5 | 5 | - |
| 8 | 8 | 1 | -7 | 7 | - |
A tiny sample can still be significant, but only when the pattern is almost perfectly consistent. With 7 pairs, if one of the larger changes (size 3 or more) had gone the other way, the p-value would rise above 0.05.
The paired t-test is the standard test for checking whether the average change between two measurements differs from zero.
| Feature | Paired t-test | Wilcoxon signed-rank test |
|---|---|---|
| What it uses | The size of each change | The position of each change in the line, plus its direction |
| What it tests | Whether the average change is zero | Whether increases and decreases balance |
| What it needs from the data | Changes that spread evenly around the average in a bell shape | Changes that look roughly like a mirror image around their middle, with no bell shape needed |
| Very large changes | Can dominate the average | Count only as the last position in the line |
| Measure of how big the change is | A gap measured in standard deviations (Cohen's d) | r, which shows how consistently the changes point the same way |
| Best for | Measured numbers whose changes are roughly bell-shaped | Ratings, changes with a few extreme values, and small samples |
Every test gives trustworthy results only when some conditions hold. These are called assumptions. For this test they are modest.
Only complete pairs are included. Anyone missing either measurement is left out, so report how many pairs the test used.
The output lists the median and the mean for each measurement and for the change between them. The median is the middle value, so half the people score above it and half below. The median difference is the headline number: the typical change per person. The interpretation states its direction and size in the units of your variable.
The significance level tells you how sure you can be that the change is real. AnalyZ Solutions reports it as 5%, 1% or 0.1%, and the smaller the percentage, the stronger the evidence. "Significant at the 5% level" means that if the measurements really made no difference, a pattern this lopsided would appear by luck in fewer than 5 samples out of 100. A result that is not significant means the evidence is not strong enough to claim a consistent change. That is not the same as showing that nothing changed.
The effect size r tells you how consistently the changes point the same way, which is a separate question from how sure you can be. It runs from 0, when increases and decreases balance, to 1, when every change goes the same way. AnalyZ Solutions labels it negligible below 0.1, small from 0.1 to 0.3, medium from 0.3 to 0.5 and large above 0.5. A high value means most of the changes point the same way.
Open Inferential Analysis, choose Non-parametric Tests, then Wilcoxon Signed-Rank.
The figures below are invented to show the steps, and they follow the results tables in AnalyZ Solutions, with a few columns left out to save space. Suppose 25 patients rated their pain from 0 to 10 before and after a treatment. Variable 1 is the before rating and Variable 2 is the after rating.
| Variable | N | Median | Mean |
|---|---|---|---|
| Before | 25 | 6.0 | 6.36 |
| After | 25 | 4.0 | 4.40 |
| Difference | 25 | -2.0 | -1.96 |
| W | p-value | Sig | r (effect) | N (pairs) |
|---|---|---|---|---|
| 4.0 | < 0.001 | *** | 0.968 | 25 |
Pain ratings fell by a median of 2 points after the treatment, from 6 to 4. The fall was consistent across patients and significant at the 0.1% level, with a large effect size. With no comparison group, the result shows that ratings changed. It cannot show that the treatment caused the change.
Using it on separate groups. If the two columns describe different people, use the Mann-Whitney U test.
Ignoring the people with no change. When many people show no change, the test has less to work with. Report how many stayed the same.
Assuming the treatment caused the change. Without a comparison group, other things could explain the change, such as people feeling better with time.
Reporting averages from a rank test. Use medians to describe the results, since the test compares positions in a line and not averages.
Open Non-parametric Tests in AnalyZ Solutions. Free to sign up, free to analyze.
Get started