Wilcoxon signed-rank test

Intermediate

What you need first. Nothing else on this path comes first. This page is part of Statistical inference.

In statistical inference, the Wilcoxon signed-rank test is a test of a symmetric paired difference that ranks the absolute differences and sums the ranks of one sign. It is the paired procedure that keeps the direction of each difference and weights that direction by the rank of the absolute difference. Its null concerns independent differences symmetric about a specified centre. That centre is a median and is also the mean when the expectation exists; a zero mean or median alone does not supply the symmetry the test needs.

Wilcoxon signed-rank test

Wilcoxon signed-rank test
Fact Value
Topic Statistical inference
Listed on Statistical inference

Motivating example

Eight students sit a short test, take a lesson, and sit a parallel test. Seven scores rise, by 1,2,3,4,5,61, 2, 3, 4, 5, 6 and 77 points. The eighth falls by 1212. A procedure that counts only signs sees seven improvements out of eight and treats the fall of 1212 as one negative sign, the same kind of evidence as a fall of half a point. A procedure that ranks the absolute differences gives that fall rank 88, the largest rank in the sample, and the conclusion moves. The signed-rank test is the second procedure. The comparison with the sign count, on these same eight numbers, is the worked example below.

Signed ranks of the paired differences

Let the paired measurements be (Xi,Yi)(X_i, Y_i) for i=1,…,ni = 1, \ldots, n, and write Di=Yi−XiD_i = Y_i - X_i. Drop every pair with Di=0D_i = 0, and let mm be the number that remain. Rank the absolute values ∣Di∣|D_i| from 11, the smallest, to mm, the largest. If several absolute values are equal they share the average of the ranks they occupy. Write rir_i for the rank attached to the iith remaining difference, including these average ranks (midranks). The signed-rank statistic W+W_+ is the sum of the ranks attached to the positive differences.[1] Without ties the ranks are 1,…,m1, \ldots, m; averaging tied ranks preserves their total m(m+1)/2m(m+1)/2. The negative ranks are whatever is left out of W+W_+, so they sum to m(m+1)/2−W+m(m+1)/2 - W_+. Either sum determines the other.

The null says that the differences are independent and symmetric about zero. Conditional on their nonzero absolute values, the signs are independent fair coins, so the 2m2^m ways of signing the ranks are equally likely. Zero is then a median of the DiD_i and is also their mean if the expectation exists. Neither a zero median nor a zero mean alone gives this null without symmetry.[1] [2]

A one-sided alternative in the positive direction rejects for large W+W_+. A two-sided alternative rejects for a value far from the null mean in either direction. The same construction tests whether a single sample is symmetric about a stated centre MM, by pairing each observation with MM and ranking those differences.[1]

What symmetry adds, and what it does not

The sign test uses only the indicators I{Di>0}I\{D_i > 0\}. The signed-rank test uses those indicators and the order of the ∣Di∣|D_i|. When the differences really are symmetric, that extra information is why the signed-rank test is the more powerful of the two against a shift. When symmetry is not a fair description, the sign test is the procedure that still matches the question it asks, which is whether positive and negative differences are equally likely. The gain and the extra assumption are the same fact.[2]

Symmetry lets the null be read as a statement about the mean only when that mean exists. Independent standard Cauchy differences are symmetric about zero and have median zero but no mean; conditional on their nonzero magnitudes, their signs are still independent fair coins. Without symmetry, a mean can sit away from zero while the median is zero, or the reverse, and a large W+W_+ is not by itself a statement about either centre. The paired tt statistic Dˉ/sDˉ\bar D / s_{\bar D} targets the mean difference and takes its critical value from the Student table on n−1n-1 degrees of freedom. The signed-rank null replaces that normal-theory reference by symmetry of the differences.[1] [2]

The worked example below shows that “uses the magnitudes” is not the same sentence as “has the smaller pp-value in this sample”. One large negative difference pulls W+W_+ down and can leave the signed-rank test short of a 5%5\% rejection while the sign count still rejects. Power is a property of the tests under a stated alternative, not a comparison of two pp-values on one sample.

The exact law obtained by signing the ranks

With untied absolute values, under the null just stated, W+W_+ is the sum of a random subset of {1,2,…,m}\{1, 2, \ldots, m\}, and every subset has probability 2−m2^{-m}.[2] That is an exact finite law, not an approximation. For a positive-direction alternative the exact pp-value is the number of subsets whose elements add to at least the observed W+W_+, divided by 2m2^m. Wilcoxon obtained those probabilities by counting the partitions of the rank sum.[3] Because that distribution is symmetric about its mean, the lower tail of the same size is the number of subsets adding to at most m(m+1)/2−W+m(m+1)/2 - W_+. When the observed value is not the mean the two tails are disjoint, so the two-sided probability is twice the smaller one. The attainable probabilities are multiples of 2−m2^{-m}, so a nominal level such as 0.050.05 need not be hit exactly.

With ties, condition on the observed nonzero magnitudes and enumerate all 2m2^m sign assignments to the labelled midranks r1,…,rmr_1, \ldots, r_m. Each difference keeps its own label even when its rank equals another. Thus W+=∑i=1mriIiW_+ = \sum_{i=1}^m r_i I_i, where the indicators Ii=I{Di>0}I_i = I\{D_i > 0\} are independent fair coins under the null. Count assignments, not distinct possible sums: several assignments can produce the same W+W_+, and each counts separately in the tail probability. This is an exact conditional law even with ties. Complementing every sign still makes the distribution symmetric about half the total rank sum.

The conditional null mean and variance follow from the same signings. Each labelled rank rir_i enters W+W_+ with probability 1/21/2, independently of the others, so E(W+∣r1,…,rm)=12∑i=1mri=m(m+1)4,\mathbb{E}(W_+ \mid r_1, \ldots, r_m) = \frac12 \sum_{i=1}^{m} r_i = \frac{m(m+1)}{4}, Var(W+∣r1,…,rm)=14∑i=1mri2.\mathrm{Var}(W_+ \mid r_1, \ldots, r_m) = \frac14 \sum_{i=1}^{m} r_i^2. Without ties, the variance simplifies to m(m+1)(2m+1)/24m(m+1)(2m+1)/24. With ties, use the squared midranks instead. The summands riIir_i I_i are independent conditional on the ranks, but generally not identically distributed because their rank weights differ. For m>20m > 20 the critical value can be approximated by comparing (W+−EW+)/VarW+(W_+ - \mathbb{E} W_+)/\sqrt{\mathrm{Var} W_+} with a normal reference.[1] For smaller mm the exact subset count is the probability, and the normal formula only describes where the observation sits.

For example, differences (1,1,−2)(1, 1, -2) have labelled midranks (1.5,1.5,3)(1.5, 1.5, 3) and observed W+=3W_+ = 3. The eight sign assignments give positive rank sums 0,1.5,1.5,3,3,4.5,4.5,60, 1.5, 1.5, 3, 3, 4.5, 4.5, 6, listed with multiplicity. Five are at least 33, so the exact upper-tail probability is 5/85/8. The conditional variance is (1.52+1.52+32)/4=3.375(1.5^2 + 1.5^2 + 3^2)/4 = 3.375, whereas the untied formula would give 3.53.5.

A zero difference is removed before mm is chosen, so it contributes neither a sign nor a rank.[1] A tie among absolute values is given the average of the ranks those values occupy. Dodge describes comparing the statistic T1T_1 based on those average ranks with the normal table.[1] That comparison is an approximation; the labelled sign count gives the exact conditional probability.

Reporting the exact count, the interval, and the approximation

When the sum of the positive ranks is the statistic and m<50m < 50, the critical value for untied absolute values is read from the ordinary untied signed-rank table. When m>20m > 20, that critical value can be approximated from the normal table. A two-sided test rejects when the statistic is smaller than wα/2w_{\alpha/2} or larger than w1−α/2w_{1-\alpha/2}, the lower and upper critical values.[1] For a one-sided question, state the direction before seeing W+W_+, report mm after zeros have been dropped, and report the subset count when the absolute values are untied and mm is small.

An interval is obtained by inverting the exact two-sided test: it is the set of shifts that the test does not reject. Under the symmetry assumption the test already uses, a shift of the differences is a statement about their median. The worked example below carries out that inversion for one sample. Because the exact distribution places mass only on multiples of 2−m2^{-m}, the coverage of the inverted interval need not equal the nominal level, and the interval need not be the shortest one with its coverage.

Eight pairs and one large decline

The scores before the lesson are 18,22,19,25,21,24,20,3018, 22, 19, 25, 21, 24, 20, 30. The scores after it are 19,24,22,29,26,30,27,1819, 24, 22, 29, 26, 30, 27, 18. The differences Di=after−beforeD_i = \text{after} - \text{before} are 1,  2,  3,  4,  5,  6,  7,  −12.1,\; 2,\; 3,\; 4,\; 5,\; 6,\; 7,\; -12. None is zero and the eight absolute values are distinct, so m=8m = 8 and the ranks of ∣Di∣|D_i| are 11 through 88 in that order. The only negative rank is 88. Hence W+=1+2+3+4+5+6+7=28W_+ = 1+2+3+4+5+6+7 = 28, and the negative ranks sum to 88.

The exact reference set is the 256256 subsets of {1,…,8}\{1,\ldots,8\}. A subset sums to 2828 or more precisely when the ranks left out, the ones that would have been negative, sum to 88 or less. There is 11 such signing of negative-sum 00, 11 of sum 11 and 11 of sum 22. The counts for negative sums 33 through 88 are 2,2,3,4,52, 2, 3, 4, 5 and 66. These add to 2525, so the exact one-sided probability is P(W+≥28)=25256≈0.0977.\mathbb{P}(W_+ \ge 28) = \frac{25}{256} \approx 0.0977. The matching lower tail is P(W+≤8)=25/256\mathbb{P}(W_+ \le 8) = 25/256 as well, and the two events are disjoint, so the two-sided probability is 50/256≈0.19550/256 \approx 0.195. At a one-sided 5%5\% level the signed-rank test does not reject.

The sign test on the same differences keeps seven positive signs out of eight. Its one-sided probability is P(N+≥7)=(87)+(88)256=9256≈0.0352.\mathbb{P}(N_+ \ge 7) = \frac{\binom{8}{7}+\binom{8}{8}}{256} = \frac{9}{256} \approx 0.0352. At the same one-sided 5%5\% level the sign test does reject. The two procedures disagree because the fall of 1212 is one sign to the sign test and the rank 88 to the signed-rank test.[1]

Replace −12-12 by −1/2-1/2 and leave the other seven differences as they are. The signs are unchanged, so the sign-test probability is still 9/2569/256. The absolute values are now 1/2,1,2,3,4,5,6,71/2, 1, 2, 3, 4, 5, 6, 7, and the negative difference carries rank 11 rather than rank 88. Then W+=36−1=35W_+ = 36 - 1 = 35, and only the empty negative set and the singleton {1}\{1\} produce a positive rank sum of 3535 or 3636. The exact one-sided probability falls from 25/25625/256 to 2/256≈0.007812/256 \approx 0.00781, and the signed-rank test rejects. One observation, changed in magnitude but not in sign, reverses the signed-rank conclusion and leaves the sign test untouched.

The normal approximation is a different object from either exact probability. For m=8m = 8, E(W+)=18,Var(W+)=51.\mathbb{E}(W_+) = 18, \qquad \mathrm{Var}(W_+) = 51. The mean and the variance are those of the exact null, and the normal approximation is the reference intended for m>20m > 20.[1] The standardised value of W+=28W_+ = 28 is 10/51≈1.40010/\sqrt{51} \approx 1.400, and the corresponding upper normal probability is about 0.08070.0807. The continuity correction that wilcox.test applies by default to this approximation compares (27.5−18)/51≈1.330(27.5 - 18)/\sqrt{51} \approx 1.330 with the same normal curve and gives about 0.09170.0917.[4] Both approximations are smaller than the exact 25/25625/256. At m=8m = 8 the subset count is the probability to report.

The point estimate that accompanies the exact test is the median of the m(m+1)/2=36m(m+1)/2 = 36 averages (Di+Dj)/2(D_i + D_j)/2 with 1≤i≤j≤m1 \le i \le j \le m. For these eight differences that median is 3.53.5. With conf.int = TRUE, wilcox.test returns an estimate of the location parameter, and on these differences that estimate is this same median.[4]

The exact interval is the set of shifts that the exact two-sided test does not reject. With 256256 equally likely signings, P(W+≤3)=5/256\mathbb{P}(W_+ \le 3) = 5/256, and 5/256≤0.0255/256 \le 0.025 while P(W+≤4)=7/256>0.025\mathbb{P}(W_+ \le 4) = 7/256 > 0.025. The test that rejects only for W+≤3W_+ \le 3 or W+≥33W_+ \ge 33 therefore has two-sided size 10/25610/256. Inverting it on these differences gives the open interval from −4.5-4.5 to 66, which are the 44th and the 3333rd of the ordered pairwise averages. Every shift strictly between those endpoints leaves the untied positive rank sum between 44 and 3232. Under a continuous symmetric law the coverage of that interval is P(4≤W+≤32)=1−10256=246256≈0.9609,\mathbb{P}(4 \le W_+ \le 32) = 1 - \frac{10}{256} = \frac{246}{256} \approx 0.9609, rather than exactly 0.950.95, because the exact test cannot spend probability in fractions finer than 1/2561/256.

In R, wilcox.test(after, before, paired = TRUE, alternative = "greater") returns the statistic V=28V = 28 and the one-sided probability 0.097660.09766. The default two-sided call returns 0.19530.1953. Adding conf.int = TRUE returns the estimate 3.53.5 and the interval from −4.5-4.5 to 66. The argument exact selects whether an exact pp-value is computed. These eight differences are untied, and the returned probability matches the subset count 25/25625/256. The argument correct = TRUE, the default in the call, applies a continuity correction in the normal approximation, and that corrected probability was 0.09170.0917.[4]

Your turn. Five differences are +3,+1,0,−2,+4+3, +1, 0, -2, +4. Drop the zero, rank the remaining absolute values, and compute W+W_+ and the exact one-sided probability of a positive rank sum at least that large.

The zero is removed, so four ranks remain. The absolute values 1,2,3,41, 2, 3, 4 receive ranks 1,2,3,41, 2, 3, 4, and the negative difference carries rank 22. Thus W+=1+3+4=8W_+ = 1+3+4 = 8. Of the 1616 subsets of {1,2,3,4}\{1,2,3,4\}, the three subsets {1,3,4}\{1,3,4\}, {2,3,4}\{2,3,4\} and {1,2,3,4}\{1,2,3,4\} sum to at least 88. The probability is 3/16=0.18753/16 = 0.1875.

Magnitudes do not guarantee a smaller probability

A non-rejection is sometimes read as evidence that the median difference is zero. Here W+=28W_+ = 28 against a null mean of 1818 and a null standard deviation 51≈7.14\sqrt{51} \approx 7.14. The exact one-sided probability is 0.09770.0977. That is what a null distribution of this width does with a moderate rank sum. It is not a measurement of the shift. The median of the pairwise averages on the same differences is 3.53.5, and the exact interval in the worked example runs from −4.5-4.5 to 66: the test’s silence at 5%5\% is compatible with shifts of several points either way.

A second misreading is that the signed-rank test simply “corrects” the sign test and must therefore be more significant whenever the magnitudes are informative. On these eight differences the sign test’s one-sided probability is 9/2569/256 and the signed-rank probability is 25/25625/256. Using the magnitudes made the evidence weaker, because the one negative difference was the largest. After that difference is reduced to 1/21/2, the signed-rank probability becomes 2/2562/256 and the sign-test probability does not move. Magnitude is information. It is not a guarantee of a smaller pp-value.

Where the subset count stops

Each difference must be symmetric about the null centre, and the differences must be mutually independent.[1] [2] The ordinary untied reference table needs no ties among the absolute values; the exact 2m2^m count does not. With ties, enumerate the labelled midranks conditional on the nonzero magnitudes. Dependence between pairs, as when several pairs share a ward or a day, does not by itself bias each sign, but it does destroy the claim that all 2m2^m signings are equally likely. Without independent signs, the conditional variance need not equal ∑iri2/4\sum_i r_i^2/4; even with independent signs, the untied formula m(m+1)(2m+1)/24m(m+1)(2m+1)/24 must be replaced when there are ties.

Symmetry is an assumption about the shape of the differences, not a consequence of pairing. Pairing fixes how DiD_i is formed. A skewed difference can have median zero and mean far from zero; W+W_+ is then aimed at a centre the distribution does not have. In that case the sign test remains a test of the sign probability, and the signed-rank conclusion does not transfer to it.[2]

The subset count over {1,…,m}\{1, \ldots, m\} is the untied case of the labelled-rank enumeration. For these eight differences that count and the probability returned by wilcox.test are the same number, 25/25625/256.[2] [4]

Paired signs, unpaired ranks, and the permutation count

The sign test is the paired comparison that gives every untied difference the same weight. The Wilcoxon rank-sum test ranks observations pooled from two independent samples; it does not start from pairs. Paired samples are the design that produces the differences DiD_i. The one-sample tt test, applied to those differences, is the normal-theory comparison of the mean. A permutation test is the broader idea of which the 2m2^m signings are one case: the reference distribution is generated by a group of rearrangements that the null says are equally likely.

Check yourself

1. All eight differences in the worked example are positive. What are W+W_+ and the exact one-sided probability?

Every rank from 11 to 88 is positive, so W+=36W_+ = 36. Only one of the 256256 signings does this. The probability is 1/256≈0.003911/256 \approx 0.00391.

2. A ninth pair is added and its difference is 00. The other eight differences stay as in the worked example. What are mm and W+W_+?

The zero is dropped before ranking, so m=8m = 8 still. The remaining absolute values and their signs are unchanged, and W+W_+ is still 2828. The reference set still has 256256 signings.

3. The difference −12-12 is replaced by −30-30. It is still the unique largest absolute value, and it is still negative. What happens to W+W_+ and to the sign count?

The order of the absolute values is unchanged, so the ranks are unchanged and W+W_+ stays 2828. The signs are unchanged, so the sign count stays at seven positives out of eight. Increasing a difference that is already the largest, without changing its sign, moves neither statistic.

Paired ranks in 1945

Frank Wilcoxon introduced the ranking of paired differences in 1945, as a quick substitute for the paired comparison of means. In the paired form, ranks 1,2,…1, 2, \ldots replace the absolute differences and a negative difference gives its rank a negative sign. The probability of a small rank total is found by counting the partitions of that total, which is the subset enumeration above in the language of partitions. For eight pairs his table gives probability 0.00780.0078 for a smaller rank sum of 00, and 0.0240.024 for a smaller rank sum of 22 or less.[3] The subset counts for those same totals are 2/256=0.00782/256 = 0.0078 and 6/256=0.02346/256 = 0.0234. He also noted that Friedman’s rank method, when only two treatments are compared, reduces to the binomial test that uses the signs alone, and that the signed ranks keep the sizes as well.[3]

In 1949 Wilcoxon proposed another method to treat the zero differences that can appear between two observations.[1] The null mean m(m+1)/4m(m+1)/4, the null standard deviation, and the normal approximation for m>20m > 20 are the form in which the procedure is now calculated when the subset count is no longer the practical reference.[1]

See also

Line chart · Apriori algorithm · Asymptotic analysis · Average treatment effect · Base rate · Bayesian inference · Bayesian model · Bayesian probability

Glossary and index

References

  1. ^ a b c d e f g h i j k l m a. (pp. 571–572) b. (pp. 572–573) c. (pp. 572–573) d. (pp. 409, 573) e. (p. 572) f. (p. 571) g. (pp. 571, 574) h. (p. 572) i. (p. 486) j. (p. 572) k. (p. 572) l. (p. 571) m. (p. 572) Dodge, Yadolah (2008). The Concise Encyclopedia of Statistics. Springer. https://doi.org/10.1007/978-0-387-32833-1
  2. ^ a b c d e f g a. (Purpose and assumptions) b. (comparison with the sign test) c. (assumptions) d. (the 2m2^m signings) e. (assumptions) f. (comparison with the sign test) g. (the 2m2^m signings) NIST (2023). NIST Dataplot: Signed Rank Test. National Institute of Standards and Technology. https://www.itl.nist.gov/div898/software/dataplot/refman1/auxillar/signrank.htm
  3. ^ a b c a. (p. 82) b. (p. 82) c. (pp. 80–81) Wilcoxon, F. (1945). Individual Comparisons by Ranking Methods. Biometrics Bulletin, 1(6), 80–83. https://doi.org/10.2307/3001968
  4. ^ a b c d a. (Usage and Arguments, `correct`) b. (Usage, Arguments `conf.int`, and Value) c. (Usage, Arguments `paired`, `exact`, `correct` and `conf.int`, and Value) d. (Value) R Core Team (2026). Wilcoxon Rank Sum and Signed Rank Tests (R-devel documentation for wilcox.test). R Foundation for Statistical Computing. https://stat.ethz.ch/R-manual/R-devel/library/stats/html/wilcox.test.html
Cite this page
Plain text
StatWiki (2026). "Wilcoxon signed-rank test." StatWiki. Last updated 2 December 2026. https://www.statwiki.io/articles/wilcoxon-signed-rank-test.html
BibTeX
@misc{statwiki_wilcoxon_signed_rank_test,
  author = {{StatWiki}},
  title = {{Wilcoxon signed-rank test}},
  year = {2026},
  url = {https://www.statwiki.io/articles/wilcoxon-signed-rank-test.html},
  urldate = {2026-12-02},
  note = {StatWiki, last updated 2 December 2026}
}