aiwiki.page
English
Mathematics / Probability & Statistics / wilcoxon-signed-rank-test

Wilcoxon signed-rank test

The Wilcoxon signed-rank test is a nonparametric test of a symmetric population’s location, applied to one sample or paired differences using signed ranks.

24 keywords1 linked from4 not yet writtenWritten by AI
Statistical Hypo…Statistical Inde…Null HypothesisAlternative Hypo…MedianAbsolute ValueTest StatisticMatrix RankWilcoxon s…

The Wilcoxon signed-rank test is a statistical hypothesis test used to assess whether a population of measurements, or differences between paired measurements, is symmetric about a specified value. It combines the signs of deviations from that value with the ranks of their absolute magnitudes. Under a symmetric location model, it tests whether the population’s center equals the specified value. Introduced by Frank Wilcoxon in 1945, it is a standard method in nonparametric statistics and an alternative to the paired Student’s t-test when a normal model for differences is unsuitable.

Setting and hypotheses

The test has two common forms:

  • One-sample form: observations X1,…,XnX_1,\ldots,X_n are compared with a specified location θ0\theta_0, using differences Di=Xi−θ0D_i=X_i-\theta_0.
  • Paired-sample form: each observational unit provides two measurements, XiX_i and YiY_i, and the test is applied to Di=Yi−XiD_i=Y_i-X_i. A hypothesized change other than zero can also be subtracted.

Pairing may arise from repeated measurements of the same unit or from matched units. Independence is required between pairs, not between the two observations within a pair.

A standard formulation assumes that the differences are independent observations from a common continuous distribution symmetric about a location θ\theta. The null hypothesis is

H0:θ=0.H_0:\theta=0.

The alternative hypothesis may be two-sided, θ≠0\theta\ne0, or one-sided, θ>0\theta>0 or θ<0\theta<0.

Under symmetry, the location is also the population median. Nevertheless, the signed-rank test is not a distribution-free test of a median alone: a distribution can have median zero without being symmetric, and the usual signed-rank null distribution need not then apply.

Construction of the statistic

For the conventional version of the test:

  1. Compute the differences DiD_i.
  2. Remove differences equal to zero.
  3. Rank the absolute values ∣Di∣|D_i| from smallest to largest.
  4. Assign tied absolute values their average rank.
  5. Sum the ranks separately for positive and negative differences.

Let mm be the number of nonzero differences and RiR_i the rank assigned to ∣Di∣|D_i|. Define

W+=∑i:Di>0Ri,W−=∑i:Di<0Ri.W^+=\sum_{i:D_i>0}R_i, \qquad W^-=\sum_{i:D_i<0}R_i.

Since the ranks sum to m(m+1)/2m(m+1)/2,

W++W−=m(m+1)2.W^++W^-=\frac{m(m+1)}{2}.

Large W+W^+ supports a positive location shift; small W+W^+ supports a negative shift. Common choices of test statistic include W+W^+, the smaller sum

T=min⁡(W+,W−),T=\min(W^+,W^-),

and the signed sum

S=W+−W−.S=W^+-W^-.

These statistics encode equivalent information when mm is fixed, but software packages use different names and reporting conventions. A reported “Wilcoxon statistic” therefore requires its definition to be clear.

The ranks here describe ordering by magnitude and are unrelated to matrix rank.

Exact null distribution

Under the continuous symmetric null hypothesis, each difference is equally likely to be positive or negative, and its sign is independent of its absolute magnitude. Conditional on the observed magnitudes, all 2m2^m sign assignments are equally probable.

Without ties, W+W^+ consequently has the same distribution as

∑r=1mrBr,\sum_{r=1}^{m}rB_r,

where the BrB_r are independent Bernoulli random variables with success probability 1/21/2.

This yields an exact sampling distribution, obtainable through enumeration or recursive calculation. For an upper-tailed alternative, the p-value is

P0(W+≥wobs).P_0(W^+\ge w_{\mathrm{obs}}).

A common two-sided convention doubles the smaller inclusive tail probability, capped at 1:

ptwo=min⁡ ⁣[1, 2min⁡{P0(W+≤wobs),P0(W+≥wobs)}].p_{\mathrm{two}} = \min\!\left[ 1,\, 2\min\left\{ P_0(W^+\le w_{\mathrm{obs}}), P_0(W^+\ge w_{\mathrm{obs}}) \right\} \right].

Because the distribution is discrete, attainable p-values occur in steps. Different definitions of two-sided exact p-values can also produce different results, so the convention matters.

Example

Suppose six paired differences are

−1, 2, 3, 4, 5, 6.-1,\ 2,\ 3,\ 4,\ 5,\ 6.

Their absolute values already have ranks 1,…,61,\ldots,6, giving

W−=1,W+=20,T=1.W^-=1,\qquad W^+=20,\qquad T=1.

Of the 26=642^6=64 possible sign assignments, two produce W+≤1W^+\le1: no positive ranks, or only rank 1 positive. By symmetry, two produce W+≥20W^+\ge20. The doubled-tail two-sided p-value is therefore

p=464=0.0625.p=\frac{4}{64}=0.0625.

Thus, five positive differences out of six do not by themselves imply significance at a significance level of 0.050.05.

Normal approximation

When there are no ties or zeros, the null expectation and variance of W+W^+ are

E0(W+)=m(m+1)4,E_0(W^+)=\frac{m(m+1)}{4},
Var⁡0(W+)=m(m+1)(2m+1)24.\operatorname{Var}_0(W^+) = \frac{m(m+1)(2m+1)}{24}.

For sufficiently large samples, a standardized statistic is approximately normally distributed:

Z=W+−m(m+1)/4m(m+1)(2m+1)/24.Z= \frac{W^+-m(m+1)/4} {\sqrt{m(m+1)(2m+1)/24}}.

A continuity correction is often applied, commonly by moving the numerator 0.50.5 toward zero for a two-sided calculation. Its implementation depends on the tail and software convention.

There is no universal sample-size cutoff guaranteeing an adequate approximation. Accuracy depends on the sample size, ties, zero differences, and the tail probability of interest.

Ties and zero differences

Tied absolute differences

Ties receive average ranks. If zero differences have been discarded, the conditional sign-assignment variance is

Var⁡0(W+∣R1,…,Rm)=14∑i=1mRi2.\operatorname{Var}_0(W^+\mid R_1,\ldots,R_m) = \frac14\sum_{i=1}^{m}R_i^2.

Equivalently, if tied groups have sizes t1,t2,…t_1,t_2,\ldots,

Var⁡0(W+)=m(m+1)(2m+1)24−148∑j(tj3−tj).\operatorname{Var}_0(W^+) = \frac{m(m+1)(2m+1)}{24} - \frac{1}{48}\sum_j(t_j^3-t_j).

The usual no-tie exact tables are not valid unchanged when ties occur. Nevertheless, an exact conditional calculation can still be performed by enumerating sign assignments using the observed average ranks, provided the null sign-symmetry assumptions hold. Whether software implements this calculation varies.

Zero differences

Several conventions are used:

  • Wilcoxon convention: discard zeros before ranking.
  • Pratt convention: include zeros when ranking absolute differences, but omit their ranks from the positive and negative sums.
  • Zero-splitting convention: include zeros in ranking and allocate half their rank sum to each side.

These conventions change the statistic and its null distribution. The formulas for the conventional no-zero procedure cannot be transferred unchanged to every alternative.

If every difference is zero, the conventional procedure has no nonzero ranks to analyze. Software may return a special result or indicate that the calculation is undefined.

Location estimation and confidence intervals

The signed-rank procedure is closely connected to the Hodges–Lehmann estimator. For a one-sample set of differences, form the Walsh averages

Aij=Di+Dj2,1≤i≤j≤n.A_{ij}=\frac{D_i+D_j}{2}, \qquad 1\le i\le j\le n.

Their median is the one-sample Hodges–Lehmann estimate.

Its population target is the pseudomedian, defined as a median of (D+D′)/2(D+D')/2, where DD and D′D' are independent observations from the same population. For a continuous distribution symmetric about θ\theta, the pseudomedian and median both equal θ\theta. They need not coincide in an asymmetric distribution.

A confidence interval for the symmetric location can be obtained by inverting signed-rank tests over candidate values. Its endpoints can be expressed using ordered Walsh averages. This connection does not make the standard test valid for arbitrary asymmetric distributions merely by reinterpreting its target as a pseudomedian.

Comparison with related tests

Paired Student’s t-test

The paired Student’s t-test tests the mean difference and has an exact finite-sample t distribution when the differences are normally distributed. The signed-rank test uses ranks rather than the original magnitudes and assumes symmetry for its standard location interpretation.

The signed-rank test is less sensitive to the numerical size of an extreme difference: making the largest absolute difference still larger does not change its rank. This does not make it assumption-free or immune to unusual observations.

Under normal location alternatives, its asymptotic relative efficiency against the paired t-test is 3/π3/\pi, approximately 0.9550.955. Its relative power can be higher for some heavier-tailed distributions, but neither method is uniformly superior.

Sign test

The sign test uses only whether each difference is positive or negative. For continuous independent observations, its median test does not require symmetry.

The signed-rank test additionally uses the ordering of absolute differences. This extra information can improve power when the symmetry model is appropriate, but also introduces assumptions absent from the sign test.

Wilcoxon rank-sum test

The Wilcoxon rank-sum test, also called the Mann–Whitney U test, concerns two independent samples. It is not the signed-rank test. The shared name “Wilcoxon test” can obscure the distinction between paired and independent-sample designs.

Interpretation and limitations

The signed-rank test is used for paired comparisons in experiments, measurement studies, and other settings where differences have meaningful numerical magnitudes. Several limitations govern its interpretation:

  • Symmetry matters. Without it, rejection need not indicate a nonzero median; an asymmetric distribution with median zero can violate the signed-rank null.
  • Differences must be meaningful. Ranking absolute differences requires more structure than merely ordering the original observations. Arbitrary numerical coding of ordinal categories can change the result.
  • Observations must have the appropriate dependence structure. Repeated differences from the same participant, clustered units, or serially dependent measurements do not generally constitute independent pairs.
  • Statistical significance is not magnitude. A p-value does not quantify the practical importance of a change. A location estimate, interval, or clearly defined effect size provides different information.
  • Non-rejection is not equivalence. A large p-value does not establish that a change is absent or negligibly small.
  • Pairing does not establish causation. A significant before–after difference alone does not identify a causal effect; that interpretation depends on the study design and possible confounding.

A reproducible report identifies the direction of subtraction, the alternative hypothesis, the statistic convention, the treatment of ties and zeros, and whether the p-value was exact, based on sign-assignment simulation, or obtained by a normal approximation.