Degrees of Freedom Calculator

Degrees of Freedom Calculator

Find the degrees of freedom for t-tests, Welch's test, chi-square tests, ANOVA and regression, with the formula worked through for your numbers.

df = number of values − number of estimates made from them

Choose a test and fill in its numbers

What are Degrees of Freedom?

Degrees of freedom count how many values in a calculation are free to vary once you've fixed what you estimated from them.

Picture five numbers with a mean of 10. You can choose the first four freely, but the fifth is then forced so that the total is 50. Estimating the mean used up one degree of freedom, leaving four, which is why the sample variance divides by n − 1.

Degrees of freedom decide which t, chi-square or F distribution a test statistic is compared with. Get them wrong and the p-value is wrong too, especially with small samples.

Degrees of Freedom Formulas

As used throughout OpenStax Introductory Statistics and the NIST/SEMATECH e-Handbook. See Sources.

1. t-tests

One sample or paired: n − 1 · two samples pooled: n₁ + n₂ − 2
Welch: (s₁²/n₁ + s₂²/n₂)² ÷ [(s₁²/n₁)²/(n₁ − 1) + (s₂²/n₂)²/(n₂ − 1)]

2. Chi-square

Independence: (r − 1)(c − 1) · goodness of fit: k − 1 − (parameters estimated)

3. ANOVA and regression

ANOVA: k − 1 and N − k · regression: p and n − p − 1

Worked Example: A 3 × 4 Chi-Square Table

Given:
A survey cross-tabulates 3 age groups against 4 favourite news sources.
Step 1:
Fix the totals:
With row and column totals known, the last row and last column are forced
Step 2:
Count the free cells:
(3 − 1) × (4 − 1) = 2 × 3 = 6
Step 3:
Critical value at 5%:
χ²₀.₉₅(6) = 12.59
Result:
6 degrees of freedom

Using 12 (the number of cells) instead would compare the statistic with the wrong curve and make a real link much harder to detect.

Degrees of Freedom for Common Tests

A quick reference with an example for each.

Degrees of freedom formulas and examples
TestdfExample
One-sample tn − 1n = 15 → 14
Paired tpairs − 120 pairs → 19
Two-sample t (pooled)n₁ + n₂ − 212 and 15 → 25
Chi-square independence(r − 1)(c − 1)3 × 4 → 6
Goodness of fitk − 1 − p6 faces → 5
One-way ANOVAk − 1, N − k3 groups, 30 total → 2, 27
Simple regressionn − 250 points → 48

Common Degrees of Freedom Mistakes

  • Using n instead of n − 1. For a sample of 10, a t-test has 9 df.
  • Counting cells for a chi-square table. A 3 × 4 table has 6 df, not 12 or 11.
  • Rounding Welch's df up. Keep it fractional or round down; rounding up overstates significance slightly.
  • Forgetting estimated parameters in goodness of fit. Fitting a normal curve's mean and SD from the data costs 2 more df.

Degrees of Freedom FAQs

Why do degrees of freedom matter?

They choose the exact shape of the t, chi-square or F distribution used for the p-value. Fewer df means fatter tails and stricter cut-offs.

Why is the sample variance divided by n − 1?

Because deviations are measured from the sample mean, which was estimated from the same data. That uses one degree of freedom.

Can degrees of freedom be a decimal?

Yes. Welch’s t-test and some mixed models produce fractional df.

What happens with large df?

The t distribution approaches the normal distribution. Beyond about 100 df the difference is negligible.

Why does ANOVA have two df?

F is a ratio of two variance estimates, each with its own df: between groups (k − 1) and within groups (N − k).

What df does a correlation test use?

n − 2, because a straight line estimates two parameters, the slope and intercept.

Do paired tests use the number of people or measurements?

The number of pairs. 20 people measured twice gives 19 df.

What are residual degrees of freedom?

In regression, the observations left over after estimating the coefficients: n − p − 1. They’re used to estimate the error variance.

Sources

Related Tools