Given data, that is, a matrix with rows, columns 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 where the entry is the rank of within block.
Find the values
The test statistic is given by. Note that the value of Q does need to be adjusted for tied values in the data.
Finally, when n or k is large, the probability distribution of Q can be approximated by that of a chi-squared distribution. In this case the p-value is given by. If n or k is small, the approximation to chi-square becomes poor and the p-value should be obtained from tables of Q 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.
Kendall's W is a normalization of the Friedman statistic between 0 and 1.
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. An implementation of the test exists in R.
were proposed by Schaich and Hamerle as well as Conover 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. Eisinga, Heskes, Pelzer and Te Grotenhuis 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 is large and the number of blocks is small. Not all statistical packages support post-hoc analysis for Friedman's test, but user-contributed code exists that provides these facilities. Also, there is a specialized package available in R containing numerous non-parametric methods for post-hoc analysis after Friedman.