F-Distribution

F-Distribution

Definition

Core Statement

The F-Distribution is a continuous probability distribution that arises as the ratio of two chi-square distributions divided by their respective degrees of freedom. It is the foundation for ANOVA, regression F-tests, and variance ratio tests.


Purpose

  1. Test equality of variances (Levene's Test uses a related statistic).
  2. Test overall significance of regression models.
  3. Compare variance explained by groups in One-Way ANOVA.
  4. Basis for the F-statistic in multiple testing scenarios.

When to Use

F-Distribution Appears In...


Theoretical Background

Definition

If Uχ2(d1) and Vχ2(d2) are independent chi-square variables, then:

F=U/d1V/d2F(d1,d2)

The F-distribution has two degrees of freedom parameters:

Properties

Property Value
Mean d2d22 for d2>2
Mode d12d1d2d2+2 for d1>2
Support [0,) (strictly positive)
Skewness Right-skewed, approaches symmetry as d1,d2

Shape

Relationship to T-Distribution

t2(df)=F(1,df)

The square of a t-statistic with df degrees of freedom is an F-statistic with (1,df) degrees of freedom.


Worked Example: Comparing Diet Plans

Problem

A researcher compares weight loss from 3 diet plans (A, B, C).

  • Between-Group Variability (Signal): Mean Square Between (MSB) = 50.
  • Within-Group Variability (Noise): Mean Square Error (MSE) = 10.
  • Degrees of Freedom: df1=2 (3 groups - 1), df2=27 (30 subjects - 3).

Question: Is there a significant difference between diets? (α=0.05)

Solution:

  1. Calculate F-Statistic:

    F=SignalNoise=MSBMSE=5010=5.0
  2. Critical Value:

    • Lookup F0.05,2,27.
    • Table value 3.35.
  3. Decision:

    • Since 5.0>3.35, we Reject H0.

Conclusion: The variability between potential diet effects is 5 times larger than the random noise. At least one diet is significantly different.

Intuition:
If F1, the group differences are just random noise.
If F1, the group differences are "real".


Assumptions

F-tests assume:


Limitations

Pitfalls

  1. Heteroscedasticity Trap: If group variances are unequal (e.g., one group has huge spread), steady F-test gives false positives. Always Check Levene's Test. If significant, use Welch's F (ANOVA) or Heteroscedasticity-Consistent Standard Errors (Regression).
  2. Non-Normality: F-test is somewhat robust to non-normality in large samples, but fails for skewed small samples.
  3. Post-Hoc Amnesia: A significant F only says "Something is different." It doesn't say "A > B". You MUST run post-hoc tests (Tukey's HSD) to find where the difference is.


Python Implementation

from scipy.stats import f
import numpy as np
import matplotlib.pyplot as plt

# F-Distribution with df1=5, df2=20
df1, df2 = 5, 20
dist = f(df1, df2)

# Critical Value (95th percentile, one-tailed)
critical_value = dist.ppf(0.95)
print(f"F Critical Value (df1={df1}, df2={df2}, α=0.05): {critical_value:.3f}")

# P-value for observed F-statistic
observed_f = 3.2
p_value = 1 - dist.cdf(observed_f)
print(f"P-value for F = {observed_f}: {p_value:.4f}")

# Visualize Different df Combinations
x = np.linspace(0, 5, 500)
for (df1, df2) in [(2, 10), (5, 20), (10, 50)]:
    plt.plot(x, f(df1, df2).pdf(x), label=f'df1={df1}, df2={df2}')

plt.xlabel('F')
plt.ylabel('Density')
plt.title('F-Distribution for Various df')
plt.legend()
plt.grid(alpha=0.3)
plt.show()

R Implementation

# Critical Value (df1=5, df2=20, α=0.05)
qf(0.95, df1 = 5, df2 = 20)

# P-value for observed F-statistic
observed_f <- 3.2
pf(observed_f, df1 = 5, df2 = 20, lower.tail = FALSE)

# Visualize
curve(df(x, df1 = 2, df2 = 10), from = 0, to = 5, col = "red", lwd = 2,
      ylab = "Density", xlab = "F", main = "F-Distributions")
curve(df(x, df1 = 5, df2 = 20), add = TRUE, col = "blue", lwd = 2)
curve(df(x, df1 = 10, df2 = 50), add = TRUE, col = "green", lwd = 2)
legend("topright", 
       legend = c("(2,10)", "(5,20)", "(10,50)"),
       col = c("red", "blue", "green"), lwd = 2, title = "(df1, df2)")

Interpretation Guide

Output Interpretation
Output Interpretation
-------- ----------------
F = 1.0 Signal = Noise. No effect.
F < 1.0 Noise > Signal. Possible model misspecification or insufficient data.
F critical value Strong Signal. The groups/model explain significant variation.
P-value < 0.05 Reject H0. Proceed to post-hoc tests to verify specifics.