Probability & Statistics

Friedman Repeated-Measures Rank Test

Rank matched treatments and compare the result with its exact tiny null distribution.

By Riano · Published · Updated · Report a correction

Friedman Repeated-Measures Rank Test

The Friedman Repeated-Measures Rank Test is a non-parametric alternative to the one-way ANOVA with repeated measures. It is used to test for differences between treatments when samples are dependent or matched, such as multiple treatments administered to the same block (or subject). The exact conditional label-randomization p-value assumes treatment-label exchangeability within independent blocks, evaluating all possible within-block permutations.

Worked Example

Let's evaluate the "Mixed" dataset scenario with 4 blocks and 3 treatments. The values are:

BlockT1T2T3
1123
2312
3231
4132

First, we rank the treatments within each block in ascending order (using average ranks for ties if they existed). The ranks are:

BlockRank 1Rank 2Rank 3
1123
2312
3231
4132

The column rank sums (Rj) for each treatment are: R1 = 7, R2 = 9, R3 = 8.

The raw statistic Q is calculated using the formula: Q = 12 / (n * k * (k + 1)) * sum(Rj^2) - 3 * n * (k + 1). For n=4 blocks and k=3 treatments: Q = 12 / (4 * 3 * 4) * (7^2 + 9^2 + 8^2) - 3 * 4 * 4 = 12 / 48 * (49 + 81 + 64) - 48 = 0.25 * 194 - 48 = 48.5 - 48 = 0.5.

Since there are no ties in this configuration, the tie correction C = 1, giving a corrected statistic of 0.5. The exact permutation p-value is calculated by examining all (3!)^4 = 1296 independent within-block permutations, computing Q for each, and finding the proportion where Q_perm >= 0.5. For this dataset, the permutation p-value is 0.9305555555555556.

Experiment

In the interactive module, you can explore the Friedman test with various dataset configurations.

  1. Change the Dataset to explore different levels of variation, from Consistent where treatments consistently rank similarly across blocks, to All tied where there is no variation at all.
  2. Modify the Focused block to inspect the specific ranking within an individual block.

Limitations

While exact enumeration is feasible for tiny designs (such as n=4 blocks and k=3 treatments, yielding 1296 assignments), it scales poorly as n and k increase. A chi-square approximation for Q is often used for larger sample sizes, but for the tiny n=4 design evaluated here, no chi-square approximation is used.

Additionally, if all values within every block are tied (e.g., all 2s), there is no rank variation (C=0), meaning the raw Q is 0 but the corrected statistic and exact p-value are theoretically undefined and thus unavailable.

References

The statistical definition of the Friedman chi-square test with tie corrections as implemented here matches common scientific computing environments.

Experience it interactively

Adjust parameters, observe in real time, and build deep intuition with Riano’s interactive Friedman Repeated-Measures Rank Test module.

Try Friedman Repeated-Measures Rank Test on Riano →

More in Probability & Statistics