Friedman test

From HandWiki
Short description: Non-parametric statistical test

The Friedman test is a non-parametric statistical test developed by Milton Friedman.[1][2][3] Similar to the parametric repeated measures ANOVA, it is used to detect differences in treatments across multiple test attempts. The procedure involves ranking each row (or block) together, then considering the values of ranks by columns. Applicable to complete block designs, it is thus a special case of the Durbin test.

Classic examples of use are:

  • [math]\displaystyle{ n }[/math] wine judges each rate [math]\displaystyle{ k }[/math] different wines. Are any of the [math]\displaystyle{ k }[/math] wines ranked consistently higher or lower than the others?
  • [math]\displaystyle{ n }[/math] welders each use [math]\displaystyle{ k }[/math] welding torches, and the ensuing welds were rated on quality. Do any of the [math]\displaystyle{ k }[/math] torches produce consistently better or worse welds?

The Friedman test is used for one-way repeated measures analysis of variance by ranks. In its use of ranks it is similar to the Kruskal–Wallis one-way analysis of variance by ranks.

The Friedman test is widely supported by many statistical software packages.


  1. Given data [math]\displaystyle{ \{x_{ij}\}_{n\times k} }[/math], that is, a matrix with [math]\displaystyle{ n }[/math] rows (the blocks), [math]\displaystyle{ k }[/math] columns (the treatments) and a single observation at the intersection of each block and treatment, calculate the ranks within each block. If there are tied values, assign to each tied value the average of the ranks that would have been assigned without ties. Replace the data with a new matrix [math]\displaystyle{ \{r_{ij}\}_{n \times k} }[/math] where the entry [math]\displaystyle{ r_{ij} }[/math] is the rank of [math]\displaystyle{ x_{ij} }[/math] within block [math]\displaystyle{ i }[/math].
  2. Find the values [math]\displaystyle{ \bar{r}_{\cdot j} = \frac{1}{n} \sum_{i=1}^n {r_{ij}} }[/math]
  3. The test statistic is given by [math]\displaystyle{ Q = \frac{12n}{k(k+1)} \sum_{j=1}^k \left(\bar{r}_{\cdot j}-\frac{k+1}{2}\right)^2 }[/math]. Note that the value of [math]\displaystyle{ Q }[/math] does need to be adjusted for tied values in the data.[4]
  4. Finally, when [math]\displaystyle{ n }[/math] or [math]\displaystyle{ k }[/math] is large (i.e. [math]\displaystyle{ n\gt 15 }[/math] or [math]\displaystyle{ k\gt 4 }[/math]), the probability distribution of [math]\displaystyle{ Q }[/math] can be approximated by that of a chi-squared distribution. In this case the p-value is given by [math]\displaystyle{ \mathbf{P}(\chi^2_{k-1} \ge Q) }[/math]. If [math]\displaystyle{ n }[/math] or [math]\displaystyle{ k }[/math] is small, the approximation to chi-square becomes poor and the p-value should be obtained from tables of [math]\displaystyle{ Q }[/math] specially prepared for the Friedman test. If the p-value is significant, appropriate post-hoc multiple comparisons tests would be performed.

Related tests

  • When using this kind of design for a binary response, one instead uses the Cochran's Q test.
  • The Sign test (with a two-sided alternative) is equivalent to a Friedman test on two groups.
  • Kendall's W is a normalization of the Friedman statistic between 0 and 1.
  • The Wilcoxon signed-rank test is a nonparametric test of nonindependent data from only two groups.
  • The Skillings–Mack test is a general Friedman-type statistic that can be used in almost any block design with an arbitrary missing-data structure.
  • The Wittkowski test is a general Friedman-Type statistics similar to Skillings-Mack test. When the data do not contain any missing value, it gives the same result as Friedman test. But if the data contain missing values, it is both, more precise and sensitive than Skillings-Mack test.[5] An implementation of the test exists in R.[6]

Post hoc analysis

Post-hoc tests were proposed by Schaich and Hamerle (1984)[7] as well as Conover (1971, 1980)[8] in order to decide which groups are significantly different from each other, based upon the mean rank differences of the groups. These procedures are detailed in Bortz, Lienert and Boehnke (2000, p. 275).[9] Eisinga, Heskes, Pelzer and Te Grotenhuis (2017)[10] provide an exact test for pairwise comparison of Friedman rank sums, implemented in R. The Eisinga c.s. exact test offers a substantial improvement over available approximate tests, especially if the number of groups ([math]\displaystyle{ k }[/math]) is large and the number of blocks ([math]\displaystyle{ n }[/math]) is small.

Not all statistical packages support post-hoc analysis for Friedman's test, but user-contributed code exists that provides these facilities (for example in SPSS,[11] and in R.[12]). Also, there is a specialized package available in R containing numerous non-parametric methods for post-hoc analysis after Friedman.[13]


  1. Friedman, Milton (December 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. doi:10.1080/01621459.1937.10503522. 
  2. Friedman, Milton (March 1939). "A correction: The use of ranks to avoid the assumption of normality implicit in the analysis of variance". Journal of the American Statistical Association 34 (205): 109. doi:10.1080/01621459.1939.10502372. 
  3. Friedman, Milton (March 1940). "A comparison of alternative tests of significance for the problem of m rankings". The Annals of Mathematical Statistics 11 (1): 86–92. doi:10.1214/aoms/1177731944. 
  4. "FRIEDMAN TEST in NIST Dataplot". August 20, 2018. 
  5. Wittkowski, Knut M. (1988). "Friedman-Type statistics and consistent multiple comparisons for unbalanced designs with missing data". Journal of the American Statistical Association 83 (404): 1163–1170. doi:10.1080/01621459.1988.10478715. 
  6. "muStat package (R code)". August 23, 2012. 
  7. Schaich, E. & Hamerle, A. (1984). Verteilungsfreie statistische Prüfverfahren. Berlin: Springer. ISBN:3-540-13776-9.
  8. Conover, W. J. (1971, 1980). Practical nonparametric statistics. New York: Wiley. ISBN:0-471-16851-3.
  9. Bortz, J., Lienert, G. & Boehnke, K. (2000). Verteilungsfreie Methoden in der Biostatistik. Berlin: Springer. ISBN:3-540-67590-6.
  10. Eisinga, R.; Heskes, T.; Pelzer, B.; Te Grotenhuis, M. (2017). "Exact p-values for pairwise comparison of Friedman rank sums, with application to comparing classifiers". BMC Bioinformatics 18 (1): 68. doi:10.1186/s12859-017-1486-2. PMID 28122501. PMC 5267387. 
  11. "Post-hoc comparisons for Friedman test". 
  12. "Post hoc analysis for Friedman's Test (R code)". February 22, 2010. 
  13. "PMCMRplus: Calculate Pairwise Multiple Comparisons of Mean Rank Sums Extended". 17 August 2022. 

Further reading