Friedman Test
The Friedman test is the non-parametric counterpart of repeated-measures ANOVA. It tests whether three or more related groups — typically the same subjects measured at multiple time points or under multiple conditions — differ in their central tendency, without requiring a normal distribution. It is the appropriate method when the normality assumption of repeated-measures ANOVA cannot be justified, particularly with small samples, ordinal outcomes, or markedly skewed data. A significant overall result is followed by post-hoc pairwise comparisons to identify which specific conditions differ from which others.
Ranking Within Subjects
The key step that distinguishes the Friedman test from the Kruskal–Wallis test is the ranking takes place. In the Kruskal–Wallis test, all observations are pooled and ranked together. In the Friedman test, each subject's observations are ranked separately within that subject, from 1 (lowest) to $k$ (highest), where $k$ is the number of conditions. This within-subject ranking removes between-subject differences entirely — just as computing within-pair differences does in the paired t-test — and concentrates the analysis on how each subject's responses order themselves across conditions.
Once ranks are assigned, the rank sum for each condition is computed by adding up the ranks that condition received across all subjects. If all conditions were equivalent, each would receive roughly equal rank sums. If one condition consistently receives low ranks (the lowest response in most subjects) and another consistently receives high ranks, the rank sums will diverge, and the test statistic will be large.
Tied observations within a subject receive the average of the ranks they would otherwise occupy.
The Test and Post-Hoc Comparisons
The rank sums are used to compute an F-statistic that is compared to the F-distribution with $k - 1$ and $(n-1)(k-1)$ degrees of freedom, where $n$ is the number of subjects and $k$ the number of conditions. A small $P$ value — below the chosen significance level — leads to rejection of the null hypothesis that all conditions are equivalent, and indicates that at least two conditions differ.
When the overall test is significant, MedCalc automatically performs pairwise post-hoc comparisons following the procedure of Conover (1999). For each pair of conditions, a test statistic is computed from the difference in mean ranks, referred to a $t$-distribution. This approach is more powerful than simply applying the Wilcoxon signed-rank test to each pair with a Bonferroni correction, particularly when several conditions are being compared.
Worked Example
Nine patients with chronic musculoskeletal pain take part in a crossover trial comparing two analgesics (Drug A and Drug B) against placebo. Each patient receives all three treatments in random order, with a washout period between. Pain is rated on a 0–10 visual analogue scale at the end of each treatment period (lower scores indicate less pain):
| Patient | Drug A | Drug B | Placebo |
|---|---|---|---|
| 1 | 2 | 4 | 7 |
| 2 | 3 | 5 | 6 |
| 3 | 1 | 4 | 8 |
| 4 | 4 | 6 | 7 |
| 5 | 2 | 3 | 5 |
| 6 | 3 | 5 | 9 |
| 7 | 5 | 4 | 7 |
| 8 | 2 | 5 | 8 |
| 9 | 4 | 6 | 8 |
Within each patient, the three scores are ranked from 1 (lowest pain, best) to 3 (highest pain, worst). In eight of the nine patients, Drug A receives rank 1, Drug B receives rank 2, and Placebo receives rank 3; patient 7 is the exception, where Drug B (4) was marginally better than Drug A (5). The mean ranks across all nine patients are:
| Drug A | Drug B | Placebo | |
|---|---|---|---|
| Mean rank | 1.11 | 1.89 | 3.00 |
Following Conover (1999), the Friedman test gives $F = 73.0$ with $\text{df} = (2, 16)$, $P < 0.001$. The null hypothesis that all three conditions are equivalent is firmly rejected.
Post-hoc pairwise comparisons (Conover's method) show:
- Drug A vs Drug B: $P = 0.031$ — Drug A produced significantly lower pain scores than Drug B.
- Drug A vs Placebo: $P < 0.001$ — Drug A was markedly better than placebo.
- Drug B vs Placebo: $P < 0.001$ — Drug B was also markedly better than placebo.
Both active treatments outperform placebo clearly, and Drug A has a statistically significant advantage over Drug B, though the clinical magnitude of that advantage — a median difference of roughly one rank position — warrants consideration alongside effect size measures before drawing firm conclusions about clinical superiority.
MedCalc computes the Friedman test with Conover post-hoc pairwise comparisons in its Friedman test procedure.