4.3 The Friedman Test

Kruskal–Wallis compares \(k\) independent samples. When the samples are related — the same subjects measured under \(k\) conditions, or \(k\) treatments applied within each of \(n\) blocks — independence fails and Kruskal–Wallis is not available. Friedman’s test is the replacement, and it stands to the two-way analysis of variance as Kruskal–Wallis stands to the one-way.

Definition 4.8. Let \(k\) treatments be applied within each of \(n\) independent blocks, giving observations \(X_{ij}\) for block \(i\) and treatment \(j\). Within each block separately, replace the \(k\) observations by their ranks \(1\) to \(k\), rank \(1\) going to the smallest, and let \(R_{ij}\) be the resulting rank. Write \[R_{\cdot j} = \sum ^{n}_{i=1} R_{ij} \qquad \text {and}\qquad \overline {R}_{\cdot j} = \dfrac {R_{\cdot j}}{n}\] for the rank total and the mean rank of treatment \(j\). The Friedman test of \[H_0 : \text {the } k \text { treatments have identical effects}\] is based on the dispersion of these rank totals.

The essential step is that ranking happens within each block, never across the whole data set. That removes the block effect entirely: a consistently generous judge, or a consistently fertile plot, contributes the same set of ranks \(1\) to \(k\) as any other and cannot influence the comparison between treatments.

Theorem 4.9. Under \(H_0\), each of the \(k!\) rankings within a block is equally likely, so \(E\left (R_{\cdot j}\right ) = \dfrac {n(k+1)}{2}\), and the statistic \[F_R = \dfrac {12}{nk(k+1)}\sum ^{k}_{j=1}R_{\cdot j}^{2} \;-\; 3n(k+1)\] is distributed approximately as \(\chi ^{2}\) on \(k-1\) degrees of freedom when \(n\) is reasonably large.

Note 4.10. The equivalent form, and a trap in it. The statistic is often written \[F_R = \dfrac {12n}{k(k+1)} \left [\sum ^{k}_{j=1}\overline {R}_{\cdot j}^{\,2} - \dfrac {k(k+1)^{2}}{4}\right ],\] and this is the same quantity — but only when \(\overline {R}_{\cdot j}\) is the mean rank \(R_{\cdot j}/n\), not the rank total. Substituting the totals into the second form gives a number hundreds of times too large: on a small example with \(n = 4\), \(k = 3\) the first form returns \(3.5\) and the second, read with totals, returns \(776\).

The two forms are related by \(\sum \overline {R}_{\cdot j}^{\,2} = n^{-2}\sum R_{\cdot j}^{2}\), and the second is simply \(\dfrac {12n}{k(k+1)}\sum \left (\overline {R}_{\cdot j} - \frac {k+1}{2}\right )^{2}\) expanded — a weighted sum of squared deviations of the mean ranks from their null expectation \(\frac {k+1}{2}\), which is what makes its meaning transparent.

Note 4.11. Ties. If observations are tied within a block they receive the average of the ranks they would otherwise have occupied, and \(F_R\) is divided by \[1 - \dfrac {\sum \left (t_p^{3} - t_p\right )}{n\left (k^{3}-k\right )},\] the sum running over all groups of tied ranks in all blocks — the same shape of correction as for Kruskal–Wallis.

Critical values. For small designs, typically \(k < 6\) and \(n < 14\), exact critical values are tabulated and should be used. For \(k > 5\) or \(n > 13\) the \(\chi ^{2}_{k-1}\) approximation is adequate, and \(H_0\) is rejected when \(F_R \geq \chi ^{2}_{\alpha ,\,k-1}\).

Note 4.12. The case \(k = 2\). With two treatments the Friedman test reduces exactly to the sign test of Chapter 2 applied to the within-block differences. Writing \(a\) for the number of blocks favouring treatment 1, the algebra collapses to \(F_R = \dfrac {(n-2a)^{2}}{n}\), which is the square of the sign-test statistic \(Z = \dfrac {2a-n}{\sqrt {n}}\). 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 rather than merely similar. This is a useful check on both.

Questions on this section

Stuck on something here? Ask below and it stays attached to this topic.