Given data , that is, a
matrix with rows (the blocks), columns (the treatments) and a single observation at the intersection of each block and treatment, calculate the
rankswithin 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 as computed above does not need to be adjusted for tied values in the data.
Finally, when n or k is large (i.e. n > 15 or k > 4), 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.