5.7 Kendall’s Tau
Spearman’s coefficient is Pearson’s applied to ranks. Kendall’s is built on a different idea altogether, and where the two disagree it is usually Kendall’s that is easier to defend.
Take the \(n\) pairs \((X_i, Y_i)\) and compare them two at a time. A pair of pairs \(\left \{(X_i,Y_i),(X_j,Y_j)\right \}\) is
- (i).
- concordant if \(X\) and \(Y\) move the same way, that is if \((X_j - X_i)(Y_j - Y_i) > 0\);
- (ii).
- discordant if they move oppositely, \((X_j - X_i)(Y_j - Y_i) < 0\);
- (iii).
- tied if either difference is zero.
Write \(C\) for the number of concordant and \(D\) for the number of discordant pairs. With no ties, \[\tau _a = \dfrac {C - D}{\binom {n}{2}} = \dfrac {2(C - D)}{n(n-1)} .\]
The denominator is the total number of pairs, so \(\tau _a\) is bounded by \(\pm 1\): it reaches \(+1\) when every pair is concordant and \(-1\) when every pair is discordant.
With ties the denominator must be reduced, since tied pairs can be neither concordant nor discordant. The usual form is \(\tau _b\): \[\tau _b = \dfrac {C - D}{\sqrt {\left (\binom {n}{2} - T_X\right ) \left (\binom {n}{2} - T_Y\right )}}, \hspace {0.8cm} T_X = \sum _{p}\dfrac {t_p(t_p - 1)}{2},\] with \(T_X\) summing over groups of tied \(X\) values and \(T_Y\) likewise for \(Y\). Without ties \(T_X = T_Y = 0\) and \(\tau _b = \tau _a\).
Testing \(H_0\): no association. Under the null every ordering is equally likely, and for \(n \geq 10\) \[E(\tau ) = 0, \hspace {0.6cm} \operatorname {var}(\tau ) = \dfrac {2(2n+5)}{9n(n-1)}, \hspace {0.6cm} Z = \dfrac {\tau }{\sqrt {\operatorname {var}(\tau )}} \ \thicksim \ N(0,1).\]
Which to use. Kendall’s \(\tau \) and Spearman’s \(r_s\) test the same null hypothesis and almost always agree on whether to reject it. They differ in what the number means: \(\tau \) is a probability statement — the chance that a randomly chosen pair is concordant, less the chance it is discordant — whereas \(r_s\) has no equally direct reading. For that reason \(\tau \) is generally smaller in magnitude than \(r_s\) on the same data, and the two should never be compared with each other as though they were on one scale. Kendall’s is also the more stable of the two in small samples and under ties.
Note 5.7. \(\tau \) is the same quantity that underlies the Mann–Kendall trend test of Chapter 5: setting \(X_i = t_i\), the time index, makes \(C - D\) exactly the statistic \(S\). The trend test is Kendall’s tau between the observations and time.
Practice problems
Problem 5.1. Three fertilisers are applied within each of eight fields, giving one yield per fertiliser per field. Explain why Kruskal–Wallis is not appropriate, state which test is, and say precisely what is ranked and within what.
Show solution
Solution. Kruskal–Wallis requires the \(k\) samples to be independent. Here they are not: the three yields recorded in one field share that field’s soil, drainage and rainfall, so they are related observations, and treating them as independent would ignore the very structure the design was built to control.
The appropriate test is Friedman’s. Each field is a block. Within each field the three yields are ranked \(1\), \(2\), \(3\) separately — the ranking is done within the block, never across the whole data set. So a rich field and a poor one each contribute the ranks \(\{1,2,3\}\) and neither can influence the comparison between fertilisers. With \(b = 8\) blocks and \(k = 3\) treatments, the statistic is compared against \(\chi ^{2}\) on \(k - 1 = 2\) degrees of freedom.
Problem 5.2. Four judges each rank the same three wines. Write down the smallest and largest possible values of \(\sum R_j^{2}\), and hence the range of \(\chi ^{2}_{F}\). What arrangement of ranks produces the maximum?
Show solution
Solution. Here \(b = 4\) and \(k = 3\). Each judge awards the ranks \(1, 2, 3\), so the ranks sum to \(4 \times 6 = 24\) overall and each \(R_j\) lies between \(4\) and \(12\).
Since \(\sum R_j\) is fixed, \(\sum R_j^{2}\) is smallest when the \(R_j\) are as equal as possible and largest when they are as unequal as possible: \[\text {minimum: } (8,8,8) \Rightarrow \sum R_j^{2} = 192,\qquad \text {maximum: } (4,8,12) \Rightarrow \sum R_j^{2} = 224 .\] With \[\chi ^{2}_{F} = \dfrac {12}{4 \cdot 3 \cdot 4}\sum R_j^{2} - 3(4)(4) = \tfrac {1}{4}\sum R_j^{2} - 48,\] the range is \[0 \ \leq \ \chi ^{2}_{F}\ \leq \ 8 .\]
The maximum occurs when all four judges produce exactly the same ranking, so that one wine takes rank \(1\) from everybody, another rank \(2\), the third rank \(3\). Against \(\chi ^{2}_{0.05,2} = 5.991\) even perfect agreement among four judges on three wines is only just significant — four blocks is very little evidence.
Problem 5.3. Show that when \(k = 2\) the Friedman statistic is equivalent to the sign test applied to the \(b\) within-block differences.
Show solution
Solution. With \(k = 2\) each block is ranked \(1\) and \(2\). Let \(a\) be the number of blocks in which treatment 1 receives rank \(1\). Then \[R_1 = a(1) + (b-a)(2) = 2b - a,\qquad R_2 = a(2) + (b-a)(1) = b + a .\] Substituting into the statistic with \(k = 2\), \[\chi ^{2}_{F} = \dfrac {12}{b(2)(3)}\left [(2b-a)^{2} + (b+a)^{2}\right ] - 3b(3) = \dfrac {2}{b}\left [5b^{2} - 2ab + 2a^{2}\right ] - 9b = \dfrac {(b - 2a)^{2}}{b}.\]
Now the sign test. Under \(H_0\) each block is equally likely to favour either treatment, so \(a \sim B\!\left (b, \tfrac 12\right )\) and the standardised statistic is \[Z = \dfrac {a - \frac {b}{2}}{\sqrt {b/4}} = \dfrac {2a - b}{\sqrt {b}}, \qquad \text {so}\qquad Z^{2} = \dfrac {(2a-b)^{2}}{b} = \chi ^{2}_{F}.\]
The Friedman statistic is exactly the square of the sign-test \(Z\). Since the square of a standard normal is \(\chi ^{2}\) on one degree of freedom, and Friedman here has \(k - 1 = 1\) degree of freedom, the two tests are identical — not merely similar.
Questions on this section
Stuck on something here? Ask below and it stays attached to this topic.