Imagine you are a chef testing three different recipes for the same dish. You invite a group of food critics and ask them to rate each recipe on a scale from 1 to 10. Since the same critics are evaluating all three recipes, their ratings are dependent on individual preferences. How do you analyze the data to determine whether one recipe is significantly better than the others?
Table of Contents
ToggleThis is where the Friedman Test comes in. The Friedman Test is a non-parametric statistical test used to determine whether there are significant differences between three or more related samples. It is particularly useful when the assumptions of parametric tests like repeated-measures ANOVA are not met, such as when the data is ordinal or not normally distributed. In this blog, we will explore the history and theory behind the Friedman Test, its real-life applications, and how to perform the test using Python, R, and SPSS. We will also discuss the hypotheses involved, alternative tests, and provide a detailed analysis with a p-value greater than 0.05.
History of the Friedman Test
The Friedman Test was developed by Milton Friedman in 1937. Friedman, an American economist and statistician, made significant contributions to both economics and statistics. His work on the Friedman Test provided a robust method for comparing multiple related samples, especially in cases where the data does not meet the assumptions required for parametric tests.
The Friedman Test is widely used in various fields, including medicine, psychology, and social sciences, where the data may be ordinal or not normally distributed.
When and Why Is the Friedman Test Used?
The Friedman Test is used when:
- You have three or more related groups (e.g., different treatments, conditions, or time points).
- The dependent variable is ordinal or continuous but not normally distributed.
- You are dealing with a repeated-measures design, where the same subjects provide data under multiple conditions.
- The assumption of normality is violated, making parametric tests like repeated-measures ANOVA unsuitable.
Theory Behind the Friedman Test
The Friedman Test is based on ranking the data within each block (or subject) and then comparing the sums of these ranks across the different treatments or conditions. The test statistic follows a chi-square distribution with \( k-1 \) degrees of freedom, where \( k \) is the number of treatments or conditions.
The formula for the Friedman Test statistic is:
$$
\chi^2_F = \frac{12}{n k (k+1)} \sum_{j=1}^k R_j^2 – 3 n (k+1)
$$
Where:
– \( n \) is the number of blocks (or subjects).
– \( k \) is the number of treatments or conditions.
– \( R_j \) is the sum of ranks for the \( j^{th} \) treatment.
Hypotheses:
– **Null Hypothesis (\( H_0 \))**: There are no differences between the treatments or conditions.
– **Alternative Hypothesis (\( H_1 \))**: There are differences between at least two treatments or conditions.
Interpretation:
– If the p-value is greater than 0.05, we fail to reject the null hypothesis, suggesting that there are no significant differences between the treatments or conditions.
– If the p-value is less than or equal to 0.05, we reject the null hypothesis, indicating that there are significant differences between at least two treatments or conditions.
Real-Life Example: Financial Portfolio Performance
Let’s consider a real-life example from the field of Financial Portfolio Performance. Suppose you are comparing the monthly returns of three different investment strategies over the past year. You want to determine whether there are significant differences in the returns of these strategies, without assuming that the returns are normally distributed.
Daily Life Example:
Imagine you are an investor tracking the monthly returns of three different investment strategies: Strategy A, Strategy B, and Strategy C. You notice that the returns vary from month to month, but you want to statistically determine whether these variations are significant. By applying the Friedman Test, you can assess whether there are significant differences in the returns of the three strategies.
Hypothetical Data:
Let’s assume you have the following monthly returns (in percentage) for the three strategies over 12 months:
**Strategy A**: [2.5, 3.0, 2.8, 3.2, 2.9, 3.1, 2.7, 3.3, 2.6, 3.4, 2.4, 3.5]
**Strategy B**: [2.0, 2.2, 2.1, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1]
**Strategy C**: [1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6]
Analysis Code:
Python:
from scipy.stats import friedmanchisquare
# Sample data
strategy_a = [2.5, 3.0, 2.8, 3.2, 2.9, 3.1, 2.7, 3.3, 2.6, 3.4, 2.4, 3.5]
strategy_b = [2.0, 2.2, 2.1, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1]
strategy_c = [1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6]
# Perform Friedman Test
statistic, p_value = friedmanchisquare(strategy_a, strategy_b, strategy_c)
print(f”Friedman Test Statistic: {statistic}”)
print(f”P-value: {p_value}”)
# Interpretation
if p_value > 0.05:
print(“There are no significant differences between the strategies (fail to reject H0)”)
else:
print(“There are significant differences between at least two strategies (reject H0)”)
“`
R Code:
# Sample data
strategy_a <- c(2.5, 3.0, 2.8, 3.2, 2.9, 3.1, 2.7, 3.3, 2.6, 3.4, 2.4, 3.5)
strategy_b <- c(2.0, 2.2, 2.1, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1)
strategy_c <- c(1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6)
# Perform Friedman Test
result <- friedman.test(cbind(strategy_a, strategy_b, strategy_c))
# Print results
print(result)
# Interpretation
if (result$p.value > 0.05) {
print(“There are no significant differences between the strategies (fail to reject H0)”)
} else {
print(“There are significant differences between at least two strategies (reject H0)”)
}
“`
SPSS:
- Input the data into SPSS.
- Go to `Analyze` > `Nonparametric Tests` > `Related Samples`.
- Select the variables for the three strategies.
- Click on `Settings` and choose `Customize tests`.
- Check `Friedman’s 2-way ANOVA by ranks (k samples)`.
- Click `Run` to perform the test.
- Review the output for the test statistic and p-value.
Results:
Assuming the p-value is greater than 0.05, we would conclude that there are no significant differences between the returns of the three strategies. This means that any observed differences are likely due to random variation.
Alternative Tests
While the Friedman Test is widely used, there are several alternative tests for comparing three or more related samples, including:
- **Repeated-Measures ANOVA**: This parametric test compares the means of three or more related samples but assumes normality and sphericity.
- **Cochran’s Q Test**: This non-parametric test is used for binary data.
- **Quade Test**: This non-parametric test is an extension of the Friedman Test that accounts for differences in variability between blocks.
Each of these tests has its own strengths and weaknesses, and the choice of test may depend on the specific characteristics of the data and the research question at hand.
The Friedman Test is a powerful tool for comparing three or more related samples, especially when the assumptions of parametric tests are not met. Its robustness to non-normal distributions and ordinal data makes it a popular choice in various fields, including finance, medicine, and social sciences.
In this blog, we explored the history and theory of the Friedman Test, applied it to a real-life example in Financial Portfolio Performance, and provided analysis code in Python, R, and SPSS. We also discussed alternative tests and the importance of understanding the assumptions behind statistical tests.
FAQ
1. What is the Friedman Test used for?
– The Friedman Test is used to determine whether there are significant differences between three or more related samples.
2. Who developed the Friedman Test?
– The test was developed by Milton Friedman in 1937.
3. What are the hypotheses of the Friedman Test?
– The null hypothesis is that there are no differences between the treatments or conditions, and the alternative hypothesis is that there are differences between at least two treatments or conditions.
4. What does a p-value greater than 0.05 indicate in the Friedman Test?
– A p-value greater than 0.05 suggests that there are no significant differences between the treatments or conditions (fail to reject the null hypothesis).
5.What are the advantages of the Friedman Test over repeated-measures ANOVA?**
– The Friedman Test does not assume normality or sphericity, making it more robust for non-normal data and ordinal data.
6.What are some alternative tests for comparing three or more related samples?**
– Alternative tests include repeated-measures ANOVA, Cochran’s Q Test, and the Quade Test.
7.Can the Friedman Test be used for binary data?**
– No, the Friedman Test is not suitable for binary data. Cochran’s Q Test is more appropriate for binary data.
8.How is the Friedman Test statistic calculated?**
– The test statistic is calculated based on the ranks of the data within each block and follows a chi-square distribution.
9.What should you do if the Friedman Test indicates significant differences?**
– If the test indicates significant differences, you may need to perform post-hoc tests to determine which specific treatments or conditions differ.
10.Why is the Friedman Test popular in finance?**
– The Friedman Test is popular in finance because financial data often does not meet the assumptions of parametric tests, and the test provides a robust method for comparing related samples.
By understanding and applying the Friedman Test, you can make more informed decisions when comparing three or more related samples, especially in situations where parametric assumptions are not met.