EZ Statistics

Friedman Test

Calculator

2. Select Columns & Options

Learn More

Friedman Test

Definition

Friedman Test is a non-parametric alternative to the one-way repeated measures ANOVA. It tests for differences between three or more matched or paired groups, without requiring normality in the data distribution. The test statistic is based on the ranks of the data values within each block.

The Friedman test is used when the same subjects are measured under different conditions or treatments, and the data is ordinal or continuous. The test is sensitive to differences in the central tendency of the data, but not to differences in variance.

If the Friedman test indicates significant differences between groups, post-hoc tests can be used to determine which groups differ from each other.

Test Statistic

Q=12nk(k+1)j=1kRj23n(k+1)Q = \frac{12}{nk(k+1)}\sum_{j=1}^k R_j^2 - 3n(k+1)

Where:

  • nn = number of blocks (subjects)
  • kk = number of treatments
  • RjR_j = total rank of treatment jj
  • Qχk12Q \sim \chi^2_{k-1} when n>15n > 15 or k>4k > 4
  • QFk1,(k1)(n1)Q \sim F_{k-1, (k-1)(n-1)} for better accuracy when n15n \leq 15 and k4k \leq 4

Key Assumptions

Matched Groups: Data must be paired or matched
Ordinal Data: Measurements must be ordinal or continuous
Independent Blocks: Subjects must be independent

Practical Example

Step 1: State the Data

Scores for three treatments across five subjects:

SubjectTreatment ATreatment BTreatment C
1865
2776
3986
4654
5765
Step 2: State Hypotheses
  • H0H_0: No difference between treatments
  • HaH_a: At least two treatments differ
  • α=0.05\alpha = 0.05
Step 3: Rank Within Blocks
SubjectABC
1321
22.52.51
3321
4321
5321
RjR_j14.510.55
Step 4: Calculate Test Statistic

1. Basic Friedman statistic with b = 5 subjects and k = 3 treatments:

Q=1253(3+1)(14.52+10.52+52)35(3+1)=9.1Q = \frac{12}{5 \cdot 3(3+1)}(14.5^2 + 10.5^2 + 5^2) - 3 \cdot 5(3+1) = 9.1

2. Correction for ties:

In our data, we have one tie (7,7) in Subject 2's scores.

C=1Tnk(k21)C = 1 - \frac{\sum T}{n k(k^2-1)}

where T=(t3t)T = (t^3 - t) for each group of tt tied ranks

One pair of ties gives T=(232)=6T = (2^3 - 2) = 6

C=1653(91)=0.95C = 1 - \frac{6}{5 \cdot 3(9-1)} = 0.95

3. Adjusted test statistic:

Qadj=QC=9.10.95=9.58Q_{\text{adj}} = \frac{Q}{C} = \frac{9.1}{0.95} = 9.58
Step 5: Draw Conclusion

Critical value for χ2\chi^2 with df=2df = 2 at α=0.05\alpha = 0.05 is 5.9915.991. Since Q=9.58>5.991Q = 9.58 \gt 5.991, we reject H0H_0.

There is sufficient evidence to conclude that there are significant differences between at least two treatments.

With pp-value = 0.008317<0.050.008317 \lt 0.05, there is strong evidence to conclude that there are significant differences between at least two treatments.

Effect Size

Kendall's W

Kendall's coefficient of concordance (WW) ranges from 00 (no agreement) to 11 (complete agreement):

W=Qn(k1)W = \frac{Q}{n(k-1)}

For our example:

W=9.585(31)=0.958W = \frac{9.58}{5(3-1)} = 0.958

Interpretation guidelines:

  • W<0.3W \lt 0.3: Weak agreement
  • 0.3W0.50.3 \leq W \leq 0.5: Moderate agreement
  • W>0.5W \gt 0.5: Strong agreement

Code Examples

R
1#Example data
2data <- matrix(c(8, 6, 5, 
3                 7, 7, 6, 
4                 9, 8, 6, 
5                 6, 5, 4, 
6                 7, 6, 5), 
7               nrow = 5, byrow = TRUE)
8
9# Perform Friedman test
10friedman.test(data)
Python
1import numpy as np
2from scipy.stats import friedmanchisquare
3
4# Example data
5data = np.array([
6    [8, 6, 5],
7    [7, 7, 6],
8    [9, 8, 6],
9    [6, 5, 4],
10    [7, 6, 5]
11])
12
13# Perform Friedman test
14stat, p = friedmanchisquare(data[:, 0], data[:, 1], data[:, 2])
15
16# Output results
17print("Friedman Test Statistic:", stat)
18print("p-value:", p)

Alternative Tests

Consider these alternatives:

  • Repeated Measures ANOVA: When normality assumptions hold
  • Cochran's Q Test: For binary outcomes

Related Calculators

One-Way ANOVA Calculator

Repeated Measures ANOVA Calculator

Wilcoxon Signed-Rank Test

Chi-Square Test of Independence Calculator

Help us improve

Found an error or have a suggestion? Let us know!