Wilcoxon Signed-Rank Test
A nonparametric test that pairs two measurements from the same subject and compares the direction and size of the change using ranks.
Did the pain scores of patients in a pain management program go down compared with before treatment? If the same students rated their confidence before and after a course, did their scores change? If the same users rated two screen designs, which one got higher satisfaction?
The Wilcoxon signed-rank test is a method that compares the differences between two measurements from the same subjects using ranks and signs.
Unlike the Mann–Whitney U test, which compares two different groups, the Wilcoxon signed-rank test handles data linked one to one, such as each person's before-and-after change. It evaluates the size of the change by converting it to ranks, but you still need to check the conditions required for interpretation, such as symmetry of the distribution of differences.
In this article we'll use an example of pain scores before and after treatment to look at how the test works, how to read actual results, how it differs from the paired t test, how to report the results and what to check before the analysis.
What is the Wilcoxon signed-rank test?
The Wilcoxon signed-rank test is a nonparametric test that compares two measurements of the same person, or two observations that are paired with each other. You compute the difference for each pair, rank the differences by absolute value, and take the direction of increase or decrease into account as well.
Where the paired t test focuses on the mean difference, the Wilcoxon signed-rank test uses the rank information of the differences. However, an interpretation in terms of a location shift, specifically a difference in medians, is possible only when the assumption that the distribution of differences is symmetric holds.
What research questions is it used for?
| Research setting | What is compared | Question |
|---|---|---|
| Treatment effect | Same patients' pain before and after treatment | Has the pain score changed? |
| Training evaluation | Same students' confidence before and after training | Did confidence increase? |
| Product usability | Same users' satisfaction with the old and new UI | Do the two screens get different ratings? |
If the two groups consist of different people, you should consider methods for independent samples, such as the Mann–Whitney U test, rather than the Wilcoxon signed-rank test.
How does the test work?
For each participant, compute the difference after treatment − before treatment. In the standard Wilcoxon procedure, pairs with a difference of 0 are dropped, and the absolute values of the remaining differences are ranked. Tied differences get the average rank.
Compare the sum of negative ranks for observations that decreased with the sum of positive ranks for observations that increased. If the rank sums in the two directions are badly unbalanced, that is evidence against the null hypothesis of no change.
Worked example: comparing pain scores before and after treatment
To look at the effect of a pain management program, suppose the pain of 20 patients was rated on a 0–10 scale before treatment and 4 weeks later. Higher scores mean more severe pain, and all data are hypothetical figures made up for explanation.
| Patient | Before treatment | After treatment | After − before |
|---|---|---|---|
| 1 | 8 | 5 | -3 |
| 2 | 7 | 5 | -2 |
| 3 | 6 | 7 | +1 |
| 4 | 9 | 6 | -3 |
| 5 | 7 | 4 | -3 |
| 6 | 8 | 6 | -2 |
| 7 | 6 | 5 | -1 |
| 8 | 7 | 5 | -2 |
Only the first 8 patients are shown. The test used the full data for all 20.
How do you read the test results?
| Statistic | Example result | Interpretation |
|---|---|---|
| Total pairs | 20 | All 20 measured at both time points |
| Decreased / increased / no change | 17 / 2 / 1 | Decreases predominate |
| Wilcoxon W (two-sided) | 9 | Smaller of the signed-rank sums |
| Exact two-sided p-value | 0.000141 | Less than 0.05 |
| Median before / after | 7 / 6 | Median is lower after treatment |
In this example, the exact two-sided p = 0.000141, so a statistically significant difference is observed. Pain scores clearly tend to fall after treatment. However, the difference between the medians at the two time points (7 − 6 = 1 point) is not the same thing as the median of the individual changes.
How do you describe the size of the difference?
The p-value shows how unusual the observed signed-rank sum would be under the null hypothesis. The practical size of the change can be described further with the distribution of each participant's score change, the difference in medians, the Hodges–Lehmann location estimator, confidence intervals and so on.
Some software reports r = Z/√N, based on the Z value from the normal approximation, or the rank-biserial correlation. Record the calculation method and the rule for handling zero differences, and don't compare different effect sizes as if they were the same number.
How is it different from the paired t test?
| Criterion | Wilcoxon Signed-Rank Test | Paired t test |
|---|---|---|
| Main information | Ranks and signs of the differences | Mean of the raw-score differences |
| Main assumption | Symmetric distribution of paired differences (for location interpretation) | Normality of the differences (for small-sample inference) |
| Output | W, p-value, location and effect size | t, p-value, mean difference, confidence interval |
| Suitable example | Ordinal scores, symmetric non-normal differences | Interval-scale scores, interest in the mean difference |
Lack of normality alone doesn't mean you should always choose the Wilcoxon test. If the distribution of differences is highly asymmetric, the sign test or another robust approach may be more appropriate.
How is it different from the Mann–Whitney U test?
| Study design | Appropriate test |
|---|---|
| Comparing satisfaction between two different teams, A and B | Mann–Whitney U test |
| Comparing the same employees' satisfaction before and after training | Wilcoxon Signed-Rank Test |
| Comparing two conditions with matched pairs | Wilcoxon test, if the pairing is valid |
The Mann–Whitney U test compares the rank distributions of two independent groups. The Wilcoxon signed-rank test links observations by participant and analyzes the differences within pairs. Even when the research questions look the same, the results can differ depending on the sample structure.
What should you check before the analysis?
Are the pairs correctly matched to the same subjects?
Link the pre and post data by participant ID; an observation that exists at only one time point can't be used as a paired observation.
Is the distribution of differences appropriate?
Check the independence and distributional shape of the paired differences. If the distribution of differences is highly asymmetric, be careful about interpreting the result as a location shift.
Are there zero differences or differences with the same absolute value?
How zero differences and ties are handled affects the sample size, the test statistic and how the p-value is calculated. Check the options in your analysis software.
How do you choose between exact and approximate tests?
For small samples, you can consider an exact test based on all possible sign arrangements. For large samples, a normal approximation is often used. However, with data containing ties and zero differences, the definition of the exact test and its implementation in software can differ.
In this guide, after dropping the zero difference, the exact two-sided p-value was obtained by fully enumerating the sign-randomization distribution, conditional on the ranks, for the remaining 19 nonzero differences. So the example figures are actually computed values and may differ from a typical normal-approximation result.
How do you report the results?
A Wilcoxon signed-rank test was conducted to compare pain scores before and after the pain management program. Analysis of paired data from 20 patients showed that pain scores tended to be lower after treatment than before (median before = 7, median after = 6, W = 9, exact two-sided p < .001). One pair with no change was excluded from the test.
In other studies, report effect sizes and confidence intervals, the symmetry assumption and whether a multiple-comparison correction was applied, as needed.
How is it different from other analyses?
| Analysis | Design | Main question |
|---|---|---|
| Wilcoxon signed-rank | Same subjects, 2 time points | Is there a change? |
| Mann–Whitney U | Two independent groups | Do the two groups' distributions differ? |
| Friedman | Same subjects, 3 or more time points | Are there differences between time points? |
| Kruskal–Wallis | Three or more independent groups | Do the groups' distributions differ? |
| Sign test | Paired data, focus on direction of change | Are increases and decreases balanced? |
Where can the Wilcoxon test be used?
It can be used for symptom scores before and after treatment in health research, for the same students' self-ratings before and after an exam in education research, and for comparing the same users' ratings of two interfaces in user experience research.
The key is not the single fact that the scores aren't normally distributed, but checking whether it's a study design that calls for analyzing the differences between paired observations.
The Wilcoxon signed-rank test compares the change between two paired measurements.
When observations can be linked one to one, like the same person's scores before and after treatment, it considers both the direction and the relative size of the change.
The Wilcoxon signed-rank test evaluates differences in paired samples using ranks and signs. Don't confuse it with the Mann–Whitney U test, which analyzes independent groups, and interpret the results only after checking how zero differences and ties are handled and whether the distribution of differences is symmetric.
In actual research, rather than presenting only the p-value, it's good to also look at how many subjects' scores increased or decreased and whether the size of the change is practically meaningful. Where needed, presenting effect sizes and confidence intervals helps readers understand the results more accurately.
The core of the Wilcoxon signed-rank test is to bind two measurements of the same subject into a pair and evaluate the direction and relative size of the change. Check the study design and the characteristics of the distribution of differences, and interpret the test result together with the actual size of the change.