πŸŽ‰ 75% of content is free forever β€” Unlock Premium from $10/mo β†’
CW
Search courses…
πŸ’Ό Servicesℹ️ Aboutβœ‰οΈ ContactView Pricing Plansfrom $10

F-Test for Equality of Variances

Hypothesis TestingParametric Tests🟒 Free Lesson

Advertisement

F-Test for Equality of Variances

Hypothesis Testing

Testing Whether Groups Differ in Variability

The F-test for variances evaluates whether two populations have equal spread, a critical assumption for many statistical procedures. Understanding variance equality is essential for choosing appropriate analysis methods.

  • Quality Control β€” Comparing consistency of different manufacturing processes
  • Finance β€” Assessing whether investment portfolios have different risk levels
  • Agricultural Research β€” Testing uniformity of crop yields across treatments

The F-test for variances is the prerequisite for comparing means.


Tests Hβ‚€: σ₁² = Οƒβ‚‚Β² using the ratio of sample variances.

F-Test Statistic

F=s12s22,df1=n1βˆ’1,df2=n2βˆ’1F = \frac{s_1^2}{s_2^2}, \quad df_1 = n_1-1, \quad df_2 = n_2-1

Here,

  • FF=The F-test statistic
  • s12s_1^2=Sample variance of group 1
  • s22s_2^2=Sample variance of group 2
  • df1,df2df_1, df_2=Degrees of freedom for each group

Under Hβ‚€, F follows an F-distribution with (nβ‚βˆ’1, nβ‚‚βˆ’1) degrees of freedom.


Python Implementation

F-Test and Alternatives

import numpy as np
from scipy import stats

np.random.seed(42)
group1 = np.random.normal(50, 8, 25)   # Οƒ=8
group2 = np.random.normal(52, 12, 30)  # Οƒ=12

# F-test
F = group1.var(ddof=1) / group2.var(ddof=1)
df1, df2 = len(group1)-1, len(group2)-1

# Two-tailed p-value
p_upper = stats.f.sf(F, df1, df2)
p_lower = stats.f.cdf(F, df1, df2)
p_value = 2 * min(p_upper, p_lower)

print(f"s₁² = {group1.var(ddof=1):.4f}, sβ‚‚Β² = {group2.var(ddof=1):.4f}")
print(f"F({df1}, {df2}) = {F:.4f}")
print(f"p-value = {p_value:.4f}")

# Levene's test (more robust β€” doesn't require normality)
stat_lev, p_lev = stats.levene(group1, group2)
print(f"\nLevene's test: F={stat_lev:.4f}, p={p_lev:.4f}")
print("(Levene's is preferred β€” robust to non-normality)")

# Bartlett's test (sensitive to normality)
stat_bart, p_bart = stats.bartlett(group1, group2)
print(f"Bartlett's test: χ²={stat_bart:.4f}, p={p_bart:.4f}")
print("(Bartlett's is more powerful when normality holds)")

Choosing the Right Test

Which Variance Test to Use?

TestNormality RequiredRobustUse When
F-testβœ… Yes (strictly)❌ NoPerfect normality
Levene's❌ Noβœ… YesDefault choice
Bartlett'sβœ… Yes (approximately)ModerateLarge samples, near-normal
Brown-Forsythe❌ Noβœ… YesHeavy tails

Key Takeaways

Summary: F-Test for Equality of Variances

  • Use Levene's test as the default β€” it doesn't require normality
  • F-test is sensitive to non-normality β€” type I error inflates severely
  • Variance tests matter before ANOVA β€” need to confirm homogeneity of variances
  • Large variance ratio (F greater than 1 or F << 1) suggests unequal population variances
  • Follow-up with Welch's t-test if variances are unequal
⭐

Premium Content

F-Test for Equality of Variances

Unlock this lesson and 900+ advanced tutorials with a Premium plan.

🎯End-to-end Projects
πŸ’ΌInterview Prep
πŸ“œCertificates
🀝Community Access

Already a member? Log in

Need Expert Statistics Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement