Degrees of Freedom Calculator
Compute degrees of freedom (df) for common hypothesis tests and models in seconds — including t-tests, χ² tests, ANOVA, F tests, and linear regression. Includes optional step-by-step.
Background
Degrees of freedom describe how many values can vary after accounting for constraints (like estimated parameters). In practice, df help determine which sampling distribution (t, χ², F) your test statistic follows.
How to use this calculator
- Choose a scenario (t, χ², ANOVA, F, regression).
- Enter the required inputs (sample sizes, groups, table size, etc.).
- Click Calculate to get df (and df₁/df₂ when applicable).
How this calculator works
- t-tests: df track how many independent values remain after estimating a mean (or pooled variance).
- Welch’s t: df are computed via a stable approximation and can be non-integer.
- χ² tests: df depend on table dimensions (independence) or categories and estimated parameters (GOF).
- ANOVA / F: report df for numerator (model) and denominator (error).
- Regression: df split into model (predictors) and error (leftover variation).
Formula & Equation Used
One-sample/paired t: df = n − 1
Two-sample t (pooled): df = n₁ + n₂ − 2
χ² independence: df = (r − 1)(c − 1)
χ² goodness-of-fit: df = k − 1 − m
One-way ANOVA: dfbetween = k − 1, dfwithin = N − k
Variance ratio (F): df₁ = n₁ − 1, df₂ = n₂ − 1
Regression (p predictors): dferror = n − p − 1
Example Problems & Step-by-Step Solutions
Example 1 — One-sample t-test
n = 20
- Use df = n − 1.
- df = 20 − 1 = 19.
Example 2 — χ² independence test
r = 3, c = 4
- Use df = (r − 1)(c − 1).
- df = (3 − 1)(4 − 1) = 2 · 3 = 6.
Example 3 — One-way ANOVA
k = 4 groups, N = 28
- Between-groups df = k − 1 = 4 − 1 = 3.
- Within-groups df = N − k = 28 − 4 = 24.
Frequently Asked Questions
Q: Can df be non-integer?
Yes — Welch’s t-test often produces non-integer df (software uses this routinely).
Q: Why does df decrease when I estimate parameters?
Because each estimated parameter adds a constraint — fewer values can vary freely.
Q: For χ² goodness-of-fit, what is m?
m is how many parameters you estimate from the data (e.g., estimating a mean/variance changes df).
Q: Why are there two df values for F?
F compares two variances (or model vs. error), so it uses numerator df₁ and denominator df₂.
Q: What if my class uses a different df convention?
Use your instructor’s convention — this calculator is meant for common intro statistics formulas.