Hypothesis tests
Wilcoxon Signed-Rank Test Calculator
The paired t-test's rank-based alternative: test whether paired differences are centred on zero without assuming they are normally distributed.
Have a spreadsheet? Drop a CSV here
Or . CSV, TSV or plain text. You pick which column is which after it loads — the names in your file do not have to match ours. The file is read in your browser and never uploaded.
How to read this result
V is the sum of the ranks of the positive differences. Take each pair's difference, rank the differences by size ignoring their signs, then add up the ranks that belonged to positive differences. If the treatment does nothing, positive and negative differences should carry similar rank weight, so V should sit near n(n+1)/4.
Zero differences are dropped, and the sample size drops with them. That is Wilcoxon's original handling and what R does. It also means a study where most pairs did not change can have far fewer effective observations than it appears to.
The test uses more information than a sign test. A sign test counts how many differences are positive; the signed-rank test also weights them by size, which makes it more powerful — at the cost of one extra assumption, that the differences are symmetric around their median.
Exact where possible. Without ties or zeros and with up to 40 pairs, the null distribution is enumerated exactly rather than approximated.
The formula
- the difference within pair i, with zero differences dropped
- the rank of that difference's magnitude among all the magnitudes
Under the null hypothesis V has mean n(n+1)/4 and variance n(n+1)(2n+1)/24, adjusted downward for ties.
Worked example
Nine subjects measured under two conditions
Each of nine subjects is measured twice — once under each condition. The differences are small, the sample is tiny, and there is no reason to believe they are normally distributed.
Condition 1: 1.83, 0.50, 1.62, 2.48, 1.68, 1.88, 1.55, 3.06, 1.30 Condition 2: 0.878, 0.647, 0.598, 2.05, 1.06, 1.29, 1.06, 3.14, 1.29
- Take the difference within each pair.0.952, −0.147, 1.022, 0.430, 0.620, 0.590, 0.490, −0.080, 0.010
- Rank the magnitudes, smallest to largest, ignoring sign.0.010 → 1, 0.080 → 2, 0.147 → 3, 0.430 → 4, 0.490 → 5, 0.590 → 6, 0.620 → 7, 0.952 → 8, 1.022 → 9
- Add the ranks belonging to the positive differences.V = 1 + 4 + 5 + 6 + 7 + 8 + 9 = 40
- With nine pairs, no ties and no zeros, enumerate the exact distribution of V.there are 2⁹ = 512 equally likely sign patterns
- Add the probability of every V at least this extreme, both ways.two-sided p = 0.0391
Seven of the nine differences are positive, and the two negative ones are among the smallest in magnitude — which is exactly the pattern the rank weighting is designed to detect.
Checked against R's wilcox.test(x, y, paired = TRUE).
The calculator above is loaded with these numbers by the Load the worked example button.
Assumptions, and when to use something else
- Paired observations, in matching order.
- The differences are symmetric about their median. This is the assumption that buys the extra power over a sign test. Strongly skewed differences violate it; a sign test is then the conservative fallback.
- At least ordinal differences. The magnitudes must be rankable.
- The differences are roughly normalPaired t-testSlightly more powerful, and gives a confidence interval for the mean difference.
- The two groups are different subjectsMann-Whitney U testIndependent samples need the unpaired rank test.
- The paired outcome is yes/noMcNemar's testBinary paired outcomes have their own test.
- Three or more related conditionsKruskal-Wallis testNot a perfect substitute — Friedman's test is the paired k-sample equivalent and is not implemented here — but Kruskal-Wallis covers the independent-groups case.
Questions people ask
What is the difference between the signed-rank test and the rank-sum test?
The signed-rank test is for paired data — one sample of differences. The rank-sum test (also called Mann-Whitney) is for two independent samples. Both are Wilcoxon's, which is a persistent source of confusion.
What happens to differences of exactly zero?
They are dropped, and n falls accordingly. That is Wilcoxon's original approach and what R does. It is worth noticing when many pairs are unchanged: twenty pairs with fifteen zeros is really a study with five observations.
Do I need the differences to be normally distributed?
No — that is the point of the test. You do need them to be roughly symmetric about their median for the standard interpretation. If they are badly skewed, a sign test assumes less.
Is this test less powerful than the paired t-test?
Slightly, when the data really are normal — the asymptotic efficiency is about 95%. When they are not normal, it is frequently more powerful, sometimes substantially. That trade is usually worth taking with small samples.