The Wilcoxon signed-rank test is a non-parametric statistical hypothesis test used when comparing two related samples, matched samples, or repeated measurements on a single sample to assess whether their population mean ranks differ (i.e. it is a paired difference test). It can be used as an alternative to the paired Student's t-test, t-test for matched pairs, or the t-test for dependent samples when the population cannot be assumed to be normally distributed.[1]

Images Source: Flickr. Images licensed under the Creative Commons CC-BY-SA

The Wilcoxon signed-rank test is a non-parametric statistical hypothesis test used when comparing two related samples, matched samples, or repeated measurements on a single sample to assess whether their population mean ranks differ (i.e. it is a paired difference test). It can be used as an alternative to the paired Student's t-test, t-test for matched pairs, or the t-test for dependent samples when the population cannot be assumed to be normally distributed.[1]

## History

The test is named for Frank Wilcoxon (1892–1965) who, in a single paper, proposed both it and the rank-sum test for two independent samples (Wilcoxon, 1945).[2] The test was popularized by Siegel (1956)[3] in his influential text book on non-parametric statistics. Siegel used the symbol T for the value defined below as $W$. In consequence, the test is sometimes referred to as the Wilcoxon T test, and the test statistic is reported as a value of T. Other names may include the "t-test for matched pairs" or the "t-test for dependent samples".

## Assumptions

1. Data are paired and come from the same population.
2. Each pair is chosen randomly and independent.
3. The data are measured at least on an ordinal scale, but need not be normal.

## Test procedure

Let $N$ be the sample size, the number of pairs. Thus, there are a total of 2N data points. For $i = 1, ..., N$, let $x_{1,i}$ and $x_{2,i}$ denote the measurements.

H0: median difference between the pairs is zero
H1: median difference is not zero.
1. For $i = 1, ..., N$, calculate $|x_{2,i} - x_{1,i}|$ and $\sgn(x_{2,i} - x_{1,i})$, where $\sgn$ is the sign function.
2. Exclude pairs with $|x_{2,i} - x_{1,i}| = 0$. Let $N_r$ be the reduced sample size.
3. Order the remaining $N_r$ pairs from smallest absolute difference to largest absolute difference, $|x_{2,i} - x_{1,i}|$.
4. Rank the pairs, starting with the smallest as 1. Ties receive a rank equal to the average of the ranks they span. Let $R_i$ denote the rank.
5. Calculate the test statistic $W$
$W = |\sum_{i=1}^{N_r} [\sgn(x_{2,i} - x_{1,i}) \cdot R_i]|$, the absolute value of the sum of the signed ranks.
6. As $N_r$ increases, the sampling distribution of $W$ converges to a normal distribution. Thus,
For $N_r \ge 10$, a z-score can be calculated as $z = \frac{W - 0.5}{\sigma_W}, \sigma_W = \sqrt{\frac{N_r(N_r + 1)(2N_r + 1)}{6}}$.
If $z > z_{critical}$ then reject $H_0$

For $N_r < 10$, $W$ is compared to a critical value from a reference table.[1]

If $W \ge W_{critical, N_r}$ then reject $H_0$

Alternatively, a p-value can be calculated from enumeration of all possible combinations of $W$ given $N_r$.

## Example

 $x_{2,i} - x_{1,i}$ $i_{}$ $x_{2,i}$ $x_{1,i}$ $\sgn$ $\text{abs}$ 1 125 110 1 15 2 115 122 –1 7 3 130 125 1 5 4 140 120 1 20 5 140 140 0 6 115 124 –1 9 7 140 123 1 17 8 125 137 –1 12 9 140 135 1 5 10 135 145 –1 10
order by absolute difference
 $x_{2,i} - x_{1,i}$ $i_{}$ $x_{2,i}$ $x_{1,i}$ $\sgn$ $\text{abs}$ $R_i$ $\sgn \cdot R_i$ 5 140 140 0 3 130 125 1 5 1.5 1.5 9 140 135 1 5 1.5 1.5 2 115 122 –1 7 3 –3 6 115 124 –1 9 4 –4 10 135 145 –1 10 5 –5 8 125 137 –1 12 6 –6 1 125 110 1 15 7 7 7 140 123 1 17 8 8 4 140 120 1 20 9 9
$sgn$ is the sign function, $\text{abs}$ is the absolute value, and $R_i$ is the rank. Notice that pairs 3 and 9 are tied in absolute value. They would be ranked 1 and 2, so each gets the average of those ranks, 1.5.
$N_r = 10 - 1 = 9, W = |1.5+1.5-3-4-5-6+7+8+9| = 9.$

$W < W_{\alpha = 0.05, 9} = 39 \therefore \text{fail to reject } H_0.$