The Friedman test is a non-parametric statistical test used to detect differences in treatments across multiple test attempts when the data are related (e.g., repeated measures on the same subjects or matched blocks). It is particularly useful when the assumptions for parametric tests like repeated-measures ANOVA (e.g., normality) are not met, or when the data are ordinal.
Arrange your data in a table where rows represent the subjects (or blocks) and columns represent the different treatment conditions.
For each subject (row), rank the observations from lowest to highest across the different treatment conditions (columns). Assign a rank of 1 to the smallest value, 2 to the next smallest, and so on. If there are ties within a row, assign the average of the ranks that would have been assigned.
Sum the ranks for each treatment condition (column). Let $R_j$ be the sum of ranks for the $j$-th treatment.
The traditional Friedman test statistic, often denoted as $\chi^2_F$ or $Q$, is calculated using the following formula:
This statistic approximates a chi-square distribution with $df = k-1$ degrees of freedom.
An F-statistic approximation can also be used, which follows an F-distribution with degrees of freedom $d1 = k-1$ and $d2 = (n-1)(k-1)$.
Compare your calculated statistic ($\chi^2_F$ or $F_F$) to the appropriate critical value from a chi-square or F-distribution table, or obtain the p-value using statistical software.
If you reject the null hypothesis, it means there is a statistically significant difference between at least two of the treatment conditions. Post-hoc tests are needed to identify which specific pairs differ.
A pharmaceutical company wants to compare the effectiveness of three different pain relief methods (A, B, C) for chronic back pain. They recruit 10 patients, and each patient tries all three methods. Patients rate their pain on a scale of 1 to 10 (1 = no pain, 10 = extreme pain).
Significance Level ($\alpha$): 0.05
Patient | Method A | Method B | Method C |
---|---|---|---|
1 | 7 | 5 | 4 |
2 | 8 | 6 | 7 |
3 | 6 | 4 | 3 |
4 | 9 | 7 | 6 |
5 | 5 | 3 | 2 |
6 | 7 | 6 | 5 |
7 | 8 | 5 | 4 |
8 | 6 | 5 | 3 |
9 | 7 | 4 | 3 |
10 | 8 | 6 | 4 |
Patient | Method A (Rank) | Method B (Rank) | Method C (Rank) |
---|---|---|---|
1 | 3 | 2 | 1 |
2 | 3 | 1 | 2 |
3 | 3 | 2 | 1 |
4 | 3 | 2 | 1 |
5 | 3 | 2 | 1 |
6 | 3 | 2 | 1 |
7 | 3 | 2 | 1 |
8 | 3 | 2 | 1 |
9 | 3 | 2 | 1 |
10 | 3 | 2 | 1 |
Treatment | Sum of Ranks (Rj) |
---|---|
Method A | 30 |
Method B | 19 |
Method C | 11 |
Check: $30 + 19 + 11 = 60$. Expected sum: $n \times k(k+1)/2 = 10 \times 3(4)/2 = 60$. (Correct)
$$\chi^2_F = \frac{12}{10 \times 3 \times (3+1)} (30^2 + 19^2 + 11^2) - 3 \times 10 \times (3+1)$$
$$\chi^2_F = \frac{12}{120} (900 + 361 + 121) - 120$$
$$\chi^2_F = 0.1 \times (1382) - 120 = 138.2 - 120 = \mathbf{18.2}$$
Degrees of Freedom: $d1 = k-1 = 3-1 = 2$, $d2 = (n-1)(k-1) = (10-1)(3-1) = 9 \times 2 = 18$
$$F_F = \frac{(10-1) \times 18.2}{10(3-1) - 18.2}$$
$$F_F = \frac{9 \times 18.2}{20 - 18.2} = \frac{163.8}{1.8} = \mathbf{91.0}$$
Based on the Friedman test (p-value $\approx 0.0001$), we reject the null hypothesis. There is a statistically significant difference in pain relief among the three methods (A, B, and C).
Since the overall test was significant, we conduct Nemenyi's post-hoc test to see which pairs differ.
Comparison | Absolute Difference in Mean Ranks | Significance (Difference > CD) |
---|---|---|
Method A vs. Method B | $|3.0 - 1.9| = 1.1$ | No |
Method A vs. Method C | $|3.0 - 1.1| = 1.9$ | Yes |
Method B vs. Method C | $|1.9 - 1.1| = 0.8$ | No |
Conclusion from Post-Hoc: Only Method A and Method C show a statistically significant difference in pain relief. Method C provides significantly more pain relief than Method A.