Open In App

Friedman Test

Last Updated : 22 Mar, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

The Friedman Test is a non-parametric statistical test used to detect differences in treatments across multiple test attempts. It is often used when the data is in the form of rankings or ordinal data, and when you have more than two related groups or repeated measures. The Friedman test is the non-parametric alternative to the repeated measures ANOVA and is useful when the assumptions of normality and homogeneity of variances are not met

The Friedman test is used to compare three or more related groups or repeated measures. It analyzes the ranks of the data rather than the raw values, which makes it ideal for non-parametric data.

Elements of Friedman Test

  • One group measured across multiple conditions: A single group is measured on three or more conditions or over time.
  • One dependent variable: The dependent variable can be ordinal, interval, or ratio data.

Assumptions of Friedman Test

Null and Alternate Hypothesis of Friedman Test

Null Hypothesis: There is no significant difference between the given conditions of measurement OR the probability distributions for all the conditions are the same. (Medians are same)

Alternate Hypothesis: At least 2 of them differ from each other.

H0 : M1 = M2 = M3 = ..... Mk ; M= Median
H1 : At least two of them show significant difference.

Friedman Test Formula

To calculate the test statistic for the Friedman test

F_{R}=\frac{12}{n k(k+1)} \sum R_{i}^{2}-3 n(k+1)

Where:

  • n = The number of participants or observations (individuals).
  • k = The number of conditions or measurements (groups or samples).
  • Ri = The sum of ranks for each group or condition.

Decision Rule for Friedman Test

You can make the decision on the basis of the below-mentioned rules-

  1. Calculated Value vs Table Value: If FR is greater than the critical value limits reject the Null Hypothesis. Otherwise, accept the Null Hypothesis.
  2. P-Value Approach: Compare the P-Value with Alpha ( Level of Significance). If the p-value is less than or equal to alpha then reject the Null Hypothesis. 

Post Hoc Analysis

If the null hypothesis is rejected in the Friedman test, post hoc analysis helps identify which specific pairs of experimental conditions differ. This can be done using tests like the Wilcoxon signed-rank test or Conover's test.

For the Wilcoxon signed-rank test, results for all pairs can be obtained, but a Bonferroni correction is necessary. This correction adjusts the significance level to (Given significance level / total number of pairs) to control for Type I errors.

Steps to perform Friedman Test

Let us take an example to understand how to perform this test.

Example: random people were given 3 different drugs and for each person, the reaction time corresponding to the drugs were noted. Test the claim at the 5% significance level that all the 3 drugs have the same probability distribution.

 Drug ADrug BDrug C
11.241.501.62
21.711.852.05
31.372.121.68
42.531.872.62
51.231.341.51
61.942.332.86
71.721.432.86

Step 1: Define NULL and Alternate Hypothesis

  • H0 : All three drugs have the same probability distribution. MA = MB = MC
  • H1 : At least two of them differ from each other.

Step 2: State Alpha (Level of Significance)

  • Alpha = 0.05

Step 3: Calculate Degrees of Freedom

  • DF = K-1
  • K = number of blocks to be measured.
  • Here , DF = 3-1 =2.

Step 4:  Find out the Critical Chi-Square Value.

Step 5: State Decision Rule

You can check for any of the two rules:

  • If FR ​> 5.991, reject the Null Hypothesis (H0​).
  • If FR ​≤ 5.991, fail to reject H0​.

Step 6: Assign Ranks for the drugs corresponding to each person and find the sum. 

  • Ranks will be in Ascending order.
 Ranks
 Drug ADrug BDrug C
1123
2123
3132
4213
5123
6123
7213
 ∑ = 9∑ = 13∑ = 20

Note: If in the same row 2 or more columns have the same value then the rank assigned to them is the average of the ranks they get. For example: If a row has 2 columns with value x and the ranks which they get are 4 and 5. Then both the columns will be assigned with a rank of (4+5)/2 which is 4.5.

Step 7: Calculate Test Statistic

The Friedman test statistic formula is:

F_R = \frac{12}{nK(K+1)} \sum R_j^2 - 3n(K+1)

Where:

  • n = 7 (Number of people)
  • K = 3 (Number of drugs)
  • R_j^2​ are the squared rank sums:

F_R = \frac{12}{7(3)(3+1)} [(9^2 + 13^2 + 20^2)] - 3(7)(4)

F_R = \frac{12}{7(3)(4)} [81 + 169 + 400] - 84

F_R = \frac{12}{84} [650] - 84

F_R = \frac{7800}{84} - 84

F_R ​ = 8.857

Step 8: State Results

Since FR is greater than 5.991 , We reject the Null Hypothesis.

Step 9: State Conclusion

  • All the three drugs do not have the same probability distribution.
  • You can apply the Post Hoc analysis with Wilcoxon Test to know which pairs have a significant difference between them.

Here,

Total number of pairs can be 3 (Drug A - Drug B , Drug B - Drug C , Drug A - Drug C).
The new level of significance to be considered for each pair will be 0.05/3 = 0.0166.

Implementation of Friedman Test using R

R
# R program to illustrate 
# Friedman Test 

#input the data
y <- matrix(c(1.24,1.50,1.62,
              1.71,1.85,2.05,
              1.37,2.12,1.68,
              2.53,1.87,2.62,
              1.23,1.34,1.51,
              1.94,2.33,2.86,
              1.72,1.43,2.86),
nrow = 7, byrow = TRUE,
dimnames = list(Person= as.character(1:7),Drugs = c("Drug A","Drug B","Drug C")))

#display the sample data
print(y)

Output:

R
#perform friedman test on the sample
result = friedman.test(y)
print(result)

Output:

As the p-value is less than the significance level (5%) it can be concluded that there are significant differences in the probability distribution.


Next Article
Practice Tags :

Similar Reads