Statistics Quest

Wilcoxon signed-rank test

A rank-based test for paired data (or one sample against a hypothesised median) using the ranks of the absolute differences and their signs.

W+=∑di>0rank⁡(∣di∣),W−=∑di<0rank⁡(∣di∣),T=min⁡(W+,W−)W^+ = \sum_{d_i > 0} \operatorname{rank}(|d_i|),\quad W^- = \sum_{d_i < 0} \operatorname{rank}(|d_i|),\quad T = \min(W^+, W^-)
T is the two-sided statistic; W⁺ is used for one-sided tests. Zero differences are dropped (default) before ranking.
did_i
Paired difference xi−yi−Δ0x_i - y_i - \Delta_0 (or xi−m0x_i - m_0 for one sample).
nn
Number of nonzero differences.
μT=n(n+1)4,σT2=n(n+1)(2n+1)−12∑t(t2−1)24\mu_T = \frac{n(n+1)}{4},\qquad \sigma_T^2 = \frac{n(n+1)(2n+1) - \tfrac12\sum t(t^2-1)}{24}
Normal approximation (with ties or zeros); exact null distribution of W⁺ otherwise for n ≤ 50.
tt
Size of each group of tied |d|.

When to use

Paired measurements (before/after, matched pairs) when the differences are clearly non-normal with a small sample, or the outcome is ordinal-ish but differences can be ranked.

Assumptions

  • Pairs independent of each other.
  • The distribution of differences is symmetric about its median (needed to interpret the test as being about the median difference). If not, use the sign test.

How to interpret

H₀: differences are symmetric about 0 (median difference 0). Effect size: matched-pairs rank-biserial r=(W+−W−)/(W++W−)r = (W^+ - W^-)/(W^+ + W^-), from −1 to 1.

Common mistakes

  • Using it on two independent groups (use Mann–Whitney).
  • Forgetting that zero differences are dropped, which reduces n.
  • Expecting an "exact" p-value when there are ties or zeros.

Example

Before 140, 135, 150, 142, 138, 145; after 136, 132, 143, 141, 133, 139. Differences 4, 3, 7, 1, 5, 6 are all positive: W+=21W^+ = 21, W−=0W^- = 0, T=0T = 0. Exact two-sided p=2/64=0.031p = 2/64 = 0.031; r=1r = 1 (every pair decreased).