Friedman test
Intermediate
What you need first. Nothing else on this path comes first. This page is part of Statistical inference.
In statistical inference, the Friedman test is a rank test of whether treatments differ when each treatment is observed once inside each block. It ranks the treatments inside each block and asks whether the rank totals could have arisen if, within every block, every ordering were equally likely. The usual reference distribution is chi-squared. For a small table the exact probability is the proportion of within-block permutations that produce a statistic at least as large, and that proportion need not equal the chi-squared tail.
Friedman test
| Fact | Value |
|---|---|
| Topic | Statistical inference |
| Listed on | Statistical inference |
Motivating example
Six judges score three products. The scores are a convenience; only the order inside each judge is used. Five judges put the products in the same order. The fifth does not. An additive block analysis of these six judges and three products uses the interaction mean square as its error, on degrees of freedom, and it assumes normal errors and additivity. Ranking within judges uses only the within-block orderings. On these six judges the statistic is , the exact probability under random ranking is , and the chi-squared approximation on degrees of freedom is . Both reject at . Changing the sixth judge’s order drops the statistic to and the chi-squared test no longer rejects.
Ranks within blocks
Arrange the observations as , with blocks and treatments , and with one observation in each cell. Inside block , replace the values by their ranks , using rank for the smallest. Tied values inside a block share the average of the ranks they occupy. The treatment rank total is If every ordering inside a block is equally likely and the blocks are independent, each estimates the same mean rank . The Friedman statistic without ties is The second form uses only the rank totals. Large is evidence that the treatments do not have the same effect inside the blocks. Friedman writes for the number of rows, which are the blocks, and for the number of columns, which are the treatments. Those are and here, and his integer formula in the column rank totals is .[1] [2]
When ties occur, the null variance of the ranks is no longer that of a random permutation of . The untied statistic divides by . The tie-corrected statistic replaces that denominator by , where is the sum of the squares of every within-block rank and . With no ties, , so returns to and the two formulae agree.[2]
Friedman showed that if the number of rows and the number of columns are not too small, is approximately chi-squared on degrees of freedom when the ranking is random. A second function of the same rank totals, is the two-way analysis-of-variance statistic computed on the ranks, and it is referred to on degrees of freedom. The chi-squared approximation to can be poor, and the approximation is typically preferred.[2] The two statistics are monotone functions of each other, so they order samples in the same way. They do not have the same -value. So long as the number of rows and the number of columns are not too small, Friedman’s , which is , tends to a chi-squared law on degrees of freedom.[1]
Two treatments, ties, and the exact permutation count
With two treatments, Friedman’s ranking was already identified with the binomial sign count in 1945, and the Friedman test is equivalent to the sign test.[3] [2] For there are no ties only if, in every block, one treatment is strictly above the other. Let be the number of blocks in which treatment receives rank . Then and , because each block contributes ranks adding to and there are blocks. The null mean of each rank total is . Substitution into the untied formula gives The sign test on the same blocks has null mean and null variance for the count . The square of its standardised value is , the same number as . So, with no ties, the Friedman statistic is exactly the squared normal approximation to the sign test, not a new ranking. The signed-rank test is the different procedure that would also use the sizes of the within-block differences.
The exact null for an untied table does not need the chi-squared curve. The blocks are mutually independent: the results in one block do not affect the results in the others.[2] If in addition there is no treatment difference, the orderings inside a block are equally likely, and there are rank tables. The exact -value is the proportion of those tables whose is at least as large as observed. For and that collection has tables, small enough to count. The chi-squared probability is the approximation to this count. Which of the two is being reported should be said explicitly. friedman.test reports the chi-squared form.[4]
The additive analysis of one observation per cell fits a block effect and a treatment effect and uses the interaction mean square as the error. That residual has degrees of freedom, for six blocks and three treatments, which is the denominator degrees of freedom of . The comparison assumes normal errors and additivity, because the interaction mean square is being used as the error variance. Friedman’s procedure does not form that residual. It ranks within blocks, and the null is that every ordering inside a block is equally likely.[1] The Friedman test is a nonparametric test for a randomized complete block design.[2]
Blocks, the statistic to quote, and the R function
The design is a complete block design with one observation on each treatment in each block: judges, patients, or batches, with every treatment appearing once inside each. Blocks are there so that a systematic difference between judges is removed before the treatments are compared. Ranking within the block is what removes it.[5]
Quote together with its reference. For a table as small as six blocks and three treatments, the exact permutation probability and the chi-squared probability can both be given; if only one is given, it has to be the one that was computed. friedman.test accepts a data matrix, or a formula of the form y ~ treatment | block. The value it returns is Friedman’s chi-squared statistic, together with the degrees of freedom of the approximate chi-squared distribution.[4]
The data only need to be rankable. A judge who can order three products but cannot score them has already supplied the ranks the test uses. A procedure that used the numerical gaps inside a judge would be assuming more than an order.[2] [1]
Six judges and three products
The scores, with products , and in that order, are Higher is better. Ranking within each judge, the smallest score in the row receiving rank , gives the ranks No row contains a tie. The rank totals are , and . They add to , as they must. The null mean of each total is . Then The integer form gives the same value: .
The chi-squared approximation on degrees of freedom assigns probability to the region . The upper point of that chi-squared law is , so the approximate test rejects. The exact count is available here because is finite. Of those tables, have a statistic of or more, and . The approximation and the exact probability are close, and they agree on rejection at . They are not the same number. The form is on degrees of freedom, with upper-tail probability . Reporting “” without saying which reference produced it mixes with . friedman.test returns Friedman’s chi-squared equal to on degrees of freedom, the probability .[4] [2]
The assumptions used for the exact count are that the six judges are independent and that, if the products were equivalent, each judge’s three ranks would be a random permutation. The scores are only the device that produced the ranks. Any strictly increasing transformation of a judge’s three scores would have left that judge’s ranks, and therefore , unchanged.
Change the sixth judge’s scores from to . That row’s ranks change from to . The rank totals become , and , and Now , so the chi-squared test at does not reject. One judge’s order was enough to move the statistic across the approximate critical value. The exact probability for is a larger fraction of the tables than ; the point of the change is the statistic a reader can recompute by hand, which falls from to .
If the global test rejects, the rank totals can be compared in pairs. Treatments and are declared different when with the sum of all squared within-block ranks. Here there are no ties, so , and . The quantile of on degrees of freedom is , and the threshold is . The absolute gaps are , and . At this rule separates from and from , and it does not separate from . The rule is a follow-up to a rejected global test, not a set of three fresh tests with a guaranteed family-wise error.[2]
Your turn. Four blocks and three treatments have rank totals , and . Compute , and say whether the chi-squared test on degrees of freedom rejects. The critical value is .
The null mean of each total is . The deviations are , and , and the sum of squares is . Then . Since , the approximate test does not reject.
What the chi-squared tail is approximating
The exact uses independent blocks and, inside each block, a uniform random ordering under the null. If the judges confer, or if several judges score the same session, the tables are no longer equally likely and the count is not the null probability. The chi-squared statement has a further limit of its own: it is an approximation for tables that are not too small, and Friedman’s derivation presents it as a tendency of the statistic, not as an identity. On this example the approximation is off by about in the tail probability. That is small beside . It is large enough that “the -value is ” should not be rewritten as “exactly of the tables”.[1]
The pairwise threshold above is a further approximation, a quantile times an estimated standard error of a difference of rank totals. It is not the exact permutation test of that pair. Separating from at a gap of , against a threshold of , is stable to a small change in the quantile. A gap sitting on the threshold would not be.
Blocks, the sign test, and ranks without blocks
Blocks in analysis of variance are the groups inside which the treatments are ranked. Two-factor analysis of variance is the normal-theory analysis of the same rectangular table. With one observation per cell the additive form uses the interaction mean square as its error, on degrees of freedom, and it assumes normal errors and additivity. Friedman uses only the within-block orderings. Repeated measures are the case in which the block is a person and the treatments are occasions or conditions on that person. The sign test is the Friedman statistic when and there are no ties. The Kruskal–Wallis test is the rank comparison for samples that are not arranged in blocks.
Check yourself
1. Every judge assigns ranks to products , and . There are six judges. What are the rank totals and ?
The totals are , and . They deviate from by , and . The sum of squares is , and .
2. Two treatments are compared in six blocks, and treatment is ranked higher in every block. What is ?
Here and , so . The sign count is six positives out of six, and the square of its standardised null value is the same .
3. Inside one block the two better products tie, and the third is strictly worse. Which ranks are assigned?
The worst product receives rank . The two tied products share the average of ranks and , which is . The within-block ranks are , and , in the appropriate order.
Ranks instead of a normal residual, 1937
Milton Friedman set out the method of ranks in 1937 for tables with two or more criteria of classification, precisely so that the analysis would not inherit the normality assumption of the analysis of variance. Each row is ranked, and a statistic is formed from the column mean ranks. When the rows and columns are not too few, that statistic is referred to the chi-squared distribution on one fewer degrees of freedom than the number of columns. The integer formula in the rank totals is the expression used in the worked example. In that formula is the number of rows and is the number of columns, which are and on this page. The paper’s point is the null: if the column factor has no effect, the ranks in a row are a random ranking, and no distribution is assumed for the original measurements.[1]
The same reduction, for two columns, is the sign test.[3] The form on the ranks, the tie correction, and the pairwise comparison of rank totals are the later computational account of the same ranking.[2]
See also
Line chart · Apriori algorithm · Asymptotic analysis · Average treatment effect · Base rate · Bayesian inference · Bayesian model · Bayesian probability
References
- ^ a b c d e f a. (pp. 676, 678–679) b. (pp. 678–679) c. (p. 675) d. (p. 675) e. (pp. 676, 679) f. (pp. 675–676, 678–679) Friedman, Milton (1937). The Use of Ranks to Avoid the Assumption of Normality Implicit in the Analysis of Variance. Journal of the American Statistical Association, 32(200), 675-701. https://doi.org/10.1080/01621459.1937.10503522
- ^ a b c d e f g h i j a. (the rank totals and ) b. (the tie correction) c. ( and the two critical regions) d. () e. (assumptions) f. (Description) g. (assumptions) h. ( and ) i. (multiple comparisons) j. (ties, , and ) NIST (2023). NIST Dataplot: Friedman Test. National Institute of Standards and Technology. https://www.itl.nist.gov/div898/software/dataplot/refman1/auxillar/friedman.htm
- ^ a b a. (pp. 80–81) b. (pp. 80–81) Wilcoxon, F. (1945). Individual Comparisons by Ranking Methods. Biometrics Bulletin, 1(6), 80–83. https://doi.org/10.2307/3001968
- ^ a b c a. (Value) b. (Usage, Arguments and Value) c. (Value) R Core Team (2026). Friedman Rank Sum Test (R-devel documentation for friedman.test). R Foundation for Statistical Computing. https://stat.ethz.ch/R-manual/R-devel/library/stats/html/friedman.test.html
- ^ (p. 447) Dodge, Yadolah (2008). The Concise Encyclopedia of Statistics. Springer. https://doi.org/10.1007/978-0-387-32833-1
Cite this page
StatWiki (2026). "Friedman test." StatWiki. Last updated 2 December 2026. https://www.statwiki.io/articles/friedman-test.html
@misc{statwiki_friedman_test,
author = {{StatWiki}},
title = {{Friedman test}},
year = {2026},
url = {https://www.statwiki.io/articles/friedman-test.html},
urldate = {2026-12-02},
note = {StatWiki, last updated 2 December 2026}
}