How to Run the Wilcoxon Signed-Rank Test

Tests whether the differences between two measurements of the same subjects lean one way, using ranks. The absolute differences are ranked, and the ranks of the positive and negative differences are compared. It is the paired t-test without the assumption of normality.

This tests whether the differences between two measurements of the same subjects lean one way, using ranks. It stands in for the paired t-test where normality cannot be assumed.

There are three steps. Take the difference for each pair and drop any that are zero. Rank the absolute differences from smallest to largest. Then compare W+W^+, the sum of the ranks belonging to positive differences, with WW^-, the sum belonging to negative ones.

W++W=n(n+1)2W^+ + W^- = \dfrac{n(n+1)}{2}

With no systematic difference the two sums should come out similar. The smaller of them is the test statistic WW.

Example

Eight before-and-after pairs give differences of 3, 2, −1, 4, 3, 3, 2, 3. The positive rank sum is 35 and the negative one 1, adding to 36, which matches 8×9÷28 \times 9 \div 2. With W=1W = 1, z=2.41z = -2.41 and a p-value of 0.016, the after measurements are larger at the 5% level.

Compared with counting signs alone

The sign test counts only how many differences are positive. Using the ranks of their sizes as well makes this test more likely to find a real difference, while still needing no normal distribution.

Notes

Pairs with a difference of zero point neither way and are dropped. If every difference is zero there is nothing to test.

Differences of equal size share a rank. They too are given the average rank, with the variance corrected accordingly.