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.
Contents
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). The test was popularized by Sidney Siegel (1956) in his influential textbook on non-parametric statistics. Siegel used the symbol T for a value related to, but not the same as,
Assumptions
- Data are paired and come from the same population.
- Each pair is chosen randomly and independently.
- The data are measured at least on an ordinal scale (i.e., they cannot be nominal).
Test procedure
Let
- For
i = 1 , . . . , N , calculate| x 2 , i − x 1 , i | andsgn ( x 2 , i − x 1 , i ) , wheresgn is the sign function. - Exclude pairs with
| x 2 , i − x 1 , i | = 0 . LetN r - Order the remaining
N r | x 2 , i − x 1 , i | . - 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 - Calculate the test statistic
W W = ∑ i = 1 N r [ sgn ( x 2 , i − x 1 , i ) ⋅ R i ] , the sum of the signed ranks. - Under null hypothesis,
W follows a specific distribution with no simple expression. This distribution has an expected value of 0 and a variance ofN r ( N r + 1 ) ( 2 N r + 1 ) 6 W can be compared to a critical value from a reference table.The two-sided test consists in rejectingH 0 | W | > W c r i t i c a l , N r - As
N r W converges to a normal distribution. Thus,ForN r ≥ 10 , a z-score can be calculated asz = W σ W , σ W = N r ( N r + 1 ) ( 2 N r + 1 ) 6 H 0 | z | > z c r i t i c a l
Original test
The original Wilcoxon's proposal used a different statistic. Denoted by Siegel as the T statistic, it is the smaller of the two sums of ranks of given sign; in the example given below, therefore, T would equal 3+4+5+6=18. Low values of T are required for significance. As will be obvious from the example below, T is easier to calculate by hand than W and the test is equivalent to the two-sided test described above; however, the distribution of the statistic under
Example
Effect size
To compute an effect size for the signed-rank test, one can use the rank correlation.
If the test statistic W is reported, the rank correlation r is equal to the test statistic W divided by the total rank sum S, or r = W/S. Using the above example, the test statistic is W = 9. The sample size of 9 has a total rank sum of S = (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9) = 45. Hence, the rank correlation is 9/45, so r = 0.20.
If the test statistic T is reported, an equivalent way to compute the rank correlation is with the difference in proportion between the two rank sums, which is the Kerby (2014) simple difference formula. To continue with the current example, the sample size is 9, so the total rank sum is 45. T is the smaller of the two rank sums, so T is 3 + 4 + 5 + 6 = 18. From this information alone, the remaining rank sum can be computed, because it is the total sum S minus T, or in this case 45 - 18 = 27. Next, the two rank-sum proportions are 27/45 = 60% and 18/45 = 40%. Finally, the rank correlation is the difference between the two proportions (.60 minus .40), hence r = .20.
Implementations
wilcox.test(x,y, paired=TRUE)
, where x and y are vectors of equal length.wilcoxon_test
function.