Friedman Test Calculator
Hypothesis tests
- Across 10 blocks the treatment rank sums are 14, 20 and 26, totalling 60 as they must (6 per block).
- Friedman chi-square: 12 / (10 x 3 x 4) x 1,272 - 3 x 10 x 4 = 7.20.
- With 2 degrees of freedom the chi-square tail is exp(-chi2 / 2) = 0.0273.
- Kendall's coefficient of concordance W = 7.20 / (10 x 2) = 0.360.
When the same subjects - patients, tasters, machines, weeks - are measured under every treatment, the design is blocked, and the Friedman test is its rank-based analysis. Within each block the treatments are ranked 1 to k; if treatments are equivalent the rank sums even out, and if one treatment consistently wins its blocks, its rank sum shows it. The test statistic is chi-square distributed, and Kendall's W converts it into an agreement effect size.
Enter the number of blocks and the three treatments' rank sums. The calculator returns the Friedman chi-square, the p-value, Kendall's W and the mean ranks. The Kruskal-Wallis page covers the unblocked design; Friedman is for when every subject meets every condition.
Worked examples
10 blocks, chi-square 7.20
(10 · 14 · 20 · 26)
| Friedman chi-square | 7.20 |
| p-value (chi-square, df 2) | 0.0273 |
| Kendall's W | 0.360 |
| Mean ranks | 1.4, 2.0, 2.6 |
Tied blocks, chi-square 0.00
(8 · 16 · 16 · 16)
| Friedman chi-square | 0.00 |
| p-value (chi-square, df 2) | 1.0000 |
| Kendall's W | 0.000 |
| Mean ranks | 2.0, 2.0, 2.0 |
12 blocks, chi-square 4.67
(12 · 20 · 30 · 22)
| Friedman chi-square | 4.67 |
| p-value (chi-square, df 2) | 0.0970 |
| Kendall's W | 0.194 |
| Mean ranks | 1.7, 2.5, 1.8 |
Ranking within blocks
Blocking is the design's power move: each subject's idiosyncratic level - the severe patient, the generous taster - is removed by ranking within the subject, so treatments compete only against themselves under identical conditions. The statistic is chi-square_F = 12/(nk(k+1)) x sum(R_j squared) - 3n(k+1), built purely from the treatment rank sums.
The first example: 10 blocks, 3 treatments, rank sums 14, 20, 26. The statistic is 7.20 on 2 degrees of freedom, p = 0.0273, and Kendall's W = 0.360 - moderate agreement among blocks about the treatment ordering, and enough consistency for the test to fire.
Note the family resemblance to Kruskal-Wallis: same rank-sum architecture, but the ranking is local to each block, which is what purchases the extra power when block effects are large. With 2 degrees of freedom the chi-square tail is again the exact exp(-chi2/2).
- Rank within each block, sum across blocks
- chi-square_F = 12/(nk(k+1)) sum(R_j^2) - 3n(k+1)
- Rank sums total n k(k+1)/2 - 6 per block at k = 3
- Kendall's W = chi-square_F / (n(k - 1))
Worked examples: three blocked designs
The 10-block study above: chi-square 7.20, p 0.0273, W 0.360, mean ranks 1.4, 2.0 and 2.6. The mean ranks tell the story in one line - treatment one averages rank 1.4 of 3 across its blocks, treatment three averages 2.6.
The perfectly tied design: 8 blocks, rank sums 16, 16, 16. Chi-square 0.00, p = 1.0000, W = 0.000, mean ranks all 2.0. When every treatment's ranks balance exactly, the statistic is exactly zero - the control case every implementation should reproduce.
Twelve blocks, rank sums 20, 30, 22: chi-square 4.67, p = 0.0970, W = 0.194, mean ranks 1.7, 2.5 and 1.8. A visible ordering - treatment two consistently ranked worst - that 12 blocks cannot quite certify. More blocks, or a stronger contrast, is the prescription; the effect size W of 0.194 says the signal is modest either way.
The mean ranks exactly as printed: 1.4, 2.0, 2.6 in the first example; 2.0, 2.0, 2.0 for the tied design; 1.7, 2.5, 1.8 in the third.
Kendall's W: the effect size
Kendall's coefficient of concordance W rescales the statistic into a 0-to-1 agreement measure: W = chi-square_F / (n(k-1)). It reads as the agreement among blocks about the treatment ordering - 0.360 in the first example is moderate concordance, 0.194 in the third is weak, and 0.000 in the tied example is exactly none.
W has a second life as an inter-rater reliability statistic when the 'blocks' are raters ranking the same items - the same arithmetic, a different literature. Its kinship with the average Spearman correlation between raters makes it interpretable in either world.
Report W beside the p-value as with every test on this site: the first example's p of 0.0273 with W of 0.360 and the third's p of 0.0970 with W of 0.194 show the pair discriminating 'consistent and certified' from 'suggested but modest' more finely than either number alone.
The rank-sum audit
Within each block the ranks 1..k sum to k(k+1)/2 - 6 for three treatments - so across n blocks the treatment rank sums must total 6n. The examples: 14 + 20 + 26 = 60 over 10 blocks; 16 + 16 + 16 = 48 over 8; 20 + 30 + 22 = 72 over 12. Any Friedman input failing this identity contains a ranking error - usually a block ranked across treatments from another block.
The null centre is equally checkable: under no treatment effect each rank sum expects n(k+1)/2 - 20 in the first example, where the observed 14, 20, 26 spread around it, and 16 in the tied example, where all three sit exactly on it. The statistic is a scaled sum of squared departures from that centre.
Kendall's W audits too: it must equal chi-square divided by n(k-1) - 7.20/20 = 0.360, 0.00/16 = 0.000, 4.67/24 = 0.194 - three divisions that confirm the whole chain.
After Friedman: post-hoc and alternatives
A significant Friedman licenses pairwise follow-ups - the Nemenyi test is the classical companion, comparing average ranks against a critical difference that accounts for all pairs at once. Unadjusted Wilcoxon signed-rank tests on every pair are the common shortcut and spend error rate accordingly; the signed-rank page here will happily compute them, but the multiplicity bill arrives regardless.
When the outcome is genuinely continuous and blocks are random, repeated-measures ANOVA is the parametric alternative with more power under normality and an estimable effect in original units. Friedman's kingdom is ordinal outcomes, small block counts and distributions that embarrass the ANOVA assumptions.
Missing cells break the classical test - a block must rank every treatment. Designs expecting dropout should plan for the Skillings-Mack generalisation or a mixed model rather than discovering the gap at analysis time. Ties within blocks, finally, are handled by averaged ranks with a small correction to the statistic; heavily tied blocks contribute little information either way.
Friedman in sensory and benchmarking practice
Sensory panels are the design's ancestral home: each taster samples every formulation, individual palates differ wildly in level but consistently in ordering, and ranking within taster strips the palate effect out completely. The first example's W of 0.360 is what a panel with a real but not unanimous preference looks like in numbers.
Clinical crossover and repeated-measures studies use it when the outcome is ordinal or the distributions are hostile - symptom scores across three periods, in the third example's shape (12 subjects, a consistent worst treatment, p 0.0970). The block is the patient; the treatments are the periods; the ranks absorb the between-patient chaos.
Machine benchmarking has quietly adopted the same design: algorithms are treatments, datasets are blocks, and Friedman with Nemenyi follow-ups is the standard Demsar protocol for comparing classifiers across datasets - a recommendation that made this test a fixture of machine-learning papers.
Power and the number of blocks
Friedman's power grows with blocks and with consistency, not with the raw size of treatment differences - ranks flatten magnitudes by design. Twelve blocks in the third example produced only p 0.0970 because the concordance was weak (W 0.194); ten blocks in the first sufficed because the ordering was steadier (W 0.360). Consistency is the currency this test counts.
Small-k, small-n corners coarsen the chi-square approximation: with k = 3 and few blocks, exact tables or the Iman-Davenport F refinement give better-calibrated p-values. The examples' p-values at 8 to 12 blocks should be read as close approximations - which changes no decision here, as honest approximations should not.
Design advice follows: if a pilot shows a consistent ordering, modest block counts certify it; if the ordering is marginal, no feasible block count rescues it, and the honest move is a better treatment contrast rather than a larger panel.
One sentence to carry away
Rank within each block so every subject judges only itself, sum the ranks per treatment, and the inequality of those sums - as chi-square and as Kendall's W - is the whole test. Blocked designs repay their logistical cost whenever subjects differ more than treatments do, which in sensory, clinical and benchmarking work is most of the time.
Report the blocks, the treatments and the mean ranks beside the statistic, always: 10 blocks, sums 14, 20, 26, mean ranks 1.4, 2.0, 2.6 is a finding another analyst can rebuild from scratch - the standard every test report should meet.
A note on blocks that tie everything: a block in which all treatments receive the same averaged rank contributes nothing to the statistic but still counts in n, quietly diluting W. Instruments and rating scales that cannot discriminate within a block waste the design's advantage, and a pilot that reveals many all-tied blocks is telling you to sharpen the measurement before enlarging the panel - the same lesson the tie-heavy designs teach in the Kruskal-Wallis world, one block at a time.
Keep the three examples as a pocket reference: steady ordering across 10 blocks certifies (7.20, p 0.0273); perfect balance is exactly nothing (0.00, p 1.0000); a weak ordering across 12 blocks suggests and no more (4.67, p 0.0970).
FAQs
What is the Friedman chi-square for 10 blocks with rank sums 14, 20, 26?
7.20, p 0.0273.
What is Kendall's W there?
0.360.
What do tied rank sums 16, 16, 16 give?
0.00 and p 1.0000.
And 12 blocks with sums 20, 30, 22?
4.67, p 0.0970.
What must rank sums total per block?
6 for three treatments: 60 over 10 blocks.
What are the mean ranks of the first example?
1.4, 2.0 and 2.6.