Degrees of Freedom Calculator
Calculate df for common tests.
Number of observations
Select a test type and enter your parameters
Or try one of the examples above
What Are Degrees of Freedom?
Degrees of freedom (df) represent the number of independent pieces of information available for estimating a parameter. When you use data to estimate something, you "lose" degrees of freedom.
Simple example: With 10 data points, you have 10 pieces of information. If you estimate the mean, you use one. For estimating variance, you have 10 - 1 = 9 df remaining.
Why Degrees of Freedom Matter
Degrees of freedom determine:
- The shape of t, chi-square, and F distributions
- Critical values for hypothesis tests
- Width of confidence intervals
Using incorrect df leads to wrong p-values and confidence intervals.
Common Formulas
One-Sample T-Test
df = n - 1
Testing if a sample mean differs from a hypothesized value.
Example: n = 25 → df = 24
Paired T-Test
df = n - 1
Where n = number of pairs.
Example: 30 pairs → df = 29
Two-Sample T-Test (Pooled)
df = n₁ + n₂ - 2
Comparing means of two independent groups with equal variances assumed.
Example: n₁ = 20, n₂ = 25 → df = 43
Two-Sample T-Test (Welch)
df = [(s₁²/n₁ + s₂²/n₂)²] / [(s₁²/n₁)²/(n₁-1) + (s₂²/n₂)²/(n₂-1)]
This often produces non-integer df.
Example: May give df = 41.7
Chi-Square Goodness of Fit
df = k - 1 - p
Where k = categories, p = estimated parameters.
Example: 6 categories, no estimated parameters → df = 5
Chi-Square Independence Test
df = (r - 1)(c - 1)
For r × c contingency table.
Example: 3 × 4 table → df = 2 × 3 = 6
One-Way ANOVA
Between groups: df₁ = k - 1 Within groups: df₂ = n - k
Where k = groups, n = total observations.
Example: 4 groups, 60 observations → df₁ = 3, df₂ = 56
Two-Way ANOVA
Factor A: df = a - 1 Factor B: df = b - 1 Interaction: df = (a-1)(b-1) Error: df = n - ab
Simple Linear Regression
Model: df₁ = 1 Error: df₂ = n - 2 Total: df = n - 1
Multiple Regression
Model: df₁ = p (number of predictors) Error: df₂ = n - p - 1 Total: df = n - 1
Testing individual coefficients: df = n - p - 1
The Intuition Behind df
Constraints Reduce Freedom
If you know the mean of 10 numbers, only 9 can vary freely—the 10th is determined.
Mean constraint: 10 values, 1 constraint → 9 df
Multiple Constraints
If you know both mean and variance, you've used 2 pieces of information.
Two constraints: 10 values - 2 = 8 df
Group Means
In ANOVA, each group mean is a constraint. With k groups:
- Within-group: n - k df (lost k for group means)
- Between-group: k - 1 df (k means, constrained by grand mean)
Historical Development
The concept emerged from work by Ronald Fisher in the 1920s.
Fisher realized that sample variance calculated with n in the denominator was biased. Using n - 1 (the degrees of freedom) corrected this bias.
He generalized the concept to show that different statistics have different effective sample sizes for variability estimation.
Student's t-distribution uses df to account for the uncertainty in estimating variance from the sample.
Non-Integer Degrees of Freedom
Welch's t-test and some other procedures produce non-integer df:
df = 23.7
Modern calculators and software handle these directly using continuous t-distribution functions. In the past, tables required rounding (usually down for conservatism).
df and Distribution Shape
T-Distribution
| df | Shape | t₀.₉₇₅ |
|---|---|---|
| 1 | Very heavy tails | 12.71 |
| 5 | Heavy tails | 2.57 |
| 10 | Moderate tails | 2.23 |
| 30 | Nearly normal | 2.04 |
| ∞ | Normal | 1.96 |
Chi-Square Distribution
| df | Shape | Mean |
|---|---|---|
| 1 | Highly skewed | 1 |
| 5 | Right-skewed | 5 |
| 30 | Moderate skew | 30 |
Mean = df for chi-square.
F-Distribution
F has two df parameters, affecting both numerator and denominator variability.
Residual Degrees of Freedom
In regression:
Residual df = n - p - 1
Where p = number of predictors. This is the df for:
- Standard error of regression
- t-tests for coefficients
- Confidence intervals
If you add predictors, residual df decreases, making estimates less precise.
Total vs. Error df
Total df = n - 1 (always)
This partitions into:
- Model df (explained variation)
- Error df (unexplained variation)
Model df + Error df = Total df
Common Mistakes
Forgetting estimated parameters: In goodness of fit, if you estimated the mean from data, lose 1 df.
Wrong two-sample formula: Pooled uses n₁ + n₂ - 2; Welch uses a complex formula.
Paired vs. independent: Paired uses n - 1 (pairs); independent uses n₁ + n₂ - 2.
Related Calculations
- T-Distribution Calculator — Uses df
- Chi-Square Distribution Calculator — Uses df
- F-Distribution Calculator — Uses two df
- Confidence Interval for Mean — df affects width
- Critical Value Calculator (t*) — df determines t*
Summary
Degrees of freedom count independent information pieces remaining after parameter estimation. They determine the shape of t, chi-square, and F distributions, and thus affect critical values and p-values. Each statistical test has its own df formula—from simple (n - 1 for one-sample t) to complex (Welch's formula for non-integer df). Getting df right is essential for valid statistical inference.