Skip to content

Degrees of Freedom Calculator

Degrees of freedom for t-tests (including Welch), chi-square tests, one-way ANOVA and linear regression.

Your details

Paired test: number of pairs.

Results update as you type

Degrees of freedom

29

Reference distribution
t(29)

Look up the Student t distribution with these degrees of freedom.

Step-by-step solution
  1. df = n − 1 = 30 − 1 = 29

Degrees of freedom (df) are the number of values in a calculation that are free to vary once the quantities you have already estimated are fixed. They matter because the tt, chi-square and FF distributions change shape with df: the same test statistic can be significant with 50 degrees of freedom and not with 5. Every table lookup, critical value or p-value needs the right df first.

This calculator gives the df for the eight situations met most often:

  • One-sample and paired t-tests: n−1n - 1.
  • Two-sample t-test with equal variances: n1+n2−2n_1 + n_2 - 2.
  • Welch's t-test (unequal variances): the Welch–Satterthwaite approximation, usually not a whole number.
  • Chi-square goodness of fit: categories − 1 − estimated parameters.
  • Chi-square test on a contingency table: (r−1)(c−1)(r - 1)(c - 1).
  • One-way ANOVA: k−1k - 1 between groups and N−kN - k within groups.
  • Linear regression: n−p−1n - p - 1 residual degrees of freedom.

Choose the test, enter the sample sizes (and for Welch the two standard deviations), and read the df together with the distribution to look up, such as t(29)t(29), χ2(6)\chi^2(6) or F(2,27)F(2, 27).

How to use this calculator

  1. Select the test or model from the list.
  2. Enter the counts it asks for: sample size, the two sample sizes, the number of categories, the table's rows and columns, the number of groups and total observations, or the number of predictors.
  3. For Welch, add both standard deviations; the calculator also shows the conservative df and the pooled df for comparison.
  4. Read the degrees of freedom and the reference distribution, then use them in a critical value or p-value calculation.

The formula

Each estimated quantity uses up one degree of freedom (OpenStax Introductory Statistics ch. 8–13; NIST e-Handbook §1.3.5):

Situation Degrees of freedom
One-sample or paired t n−1n - 1
Two-sample t, pooled n1+n2−2n_1 + n_2 - 2
Chi-square goodness of fit k−1−mk - 1 - m
Contingency table (r−1)(c−1)(r - 1)(c - 1)
One-way ANOVA k−1k - 1 and N−kN - k
Linear regression n−p−1n - p - 1

Welch–Satterthwaite (Welch 1947):

ν=(s12n1+s22n2)2(s12/n1)2n1−1+(s22/n2)2n2−1\nu = \frac{\left(\dfrac{s_1^2}{n_1} + \dfrac{s_2^2}{n_2}\right)^2}{\dfrac{(s_1^2/n_1)^2}{n_1 - 1} + \dfrac{(s_2^2/n_2)^2}{n_2 - 1}}

It always lies between min⁡(n1,n2)−1\min(n_1, n_2) - 1 and n1+n2−2n_1 + n_2 - 2. In ANOVA the two parts add up to the total: (k−1)+(N−k)=N−1(k - 1) + (N - k) = N - 1.

Worked example

One-sample t-test. 30 measurements → df=29df = 29; compare tt with the t(29)t(29) distribution.

Welch. Sample 1: n1=10n_1 = 10, s1=10s_1 = 10; sample 2: n2=20n_2 = 20, s2=20s_2 = 20. Then s12/n1=10s_1^2/n_1 = 10 and s22/n2=20s_2^2/n_2 = 20, so ν=302/(102/9+202/19)=900/32.164=\nu = 30^2 / (10^2/9 + 20^2/19) = 900 / 32.164 = 27.98. The pooled df would be 28 and the conservative df 9. With n1=30n_1 = 30, s1=8s_1 = 8 and n2=35n_2 = 35, s2=10s_2 = 10, ν=\nu = 62.73.

Goodness of fit. Testing whether a die is fair: 6 categories, no parameter estimated, df=5df = 5. Testing a Poisson model on 8 count classes with the mean estimated from the data: df=8−1−1=6df = 8 - 1 - 1 = 6.

Contingency table. A 3 × 4 table: df=2×3=6df = 2 \times 3 = 6.

ANOVA. 3 groups, 30 observations: F(2,27)F(2, 27), total 29.

Regression. 30 observations, 2 predictors plus intercept: 27 residual df.

Why n − 1 and not n?

Once the sample mean is known, the nn deviations xi−xˉx_i - \bar x must add up to zero. Choose any n−1n - 1 of them freely and the last one is forced. Only n−1n - 1 pieces of information remain to estimate the spread, which is why the sample variance divides by n−1n - 1 and the one-sample t statistic follows t(n−1)t(n - 1).

The same logic extends everywhere. A pooled two-sample test estimates two means (−2). A goodness-of-fit test loses one df because the expected counts must add up to the total, plus one per parameter estimated from the data. In a contingency table, once the row and column totals are fixed, only (r−1)(c−1)(r-1)(c-1) cells can be filled freely. A regression with an intercept and pp slopes estimates p+1p + 1 coefficients.

Welch degrees of freedom in practice

Welch's df is usually fractional — 27.98 for instance. Software uses it as is, and so do the critical value and p-value calculators here. With a printed table, round down to the next whole number, which makes the test slightly conservative. The very conservative rule min⁡(n1,n2)−1\min(n_1, n_2) - 1 is what some older textbooks used before computers made Welch's formula easy.

Welch's df is close to the pooled n1+n2−2n_1 + n_2 - 2 when the samples have similar sizes and variances, and falls towards min⁡(n1,n2)−1\min(n_1, n_2) - 1 when one group is both smaller and much more variable.

Frequently asked questions

How do I find the degrees of freedom for a t-test?

One-sample or paired: n − 1 (number of pairs − 1 for paired data). Two independent samples with equal variances: n₁ + n₂ − 2. With unequal variances use the Welch–Satterthwaite formula, which this calculator computes from the two standard deviations.

What are the degrees of freedom of a chi-square test?

For goodness of fit, the number of categories minus 1, minus one for each parameter estimated from the data. For a test of independence on a contingency table, (rows − 1) × (columns − 1).

What are the two degrees of freedom in an F test?

In one-way ANOVA, the numerator df is k − 1 (groups − 1) and the denominator df is N − k (observations − groups). For a regression F test they are p and n − p − 1.

Can degrees of freedom be a decimal?

Yes. Welch’s approximation and other Satterthwaite-type formulas often give fractional values. The t distribution is defined for any positive df, so software uses the decimal value directly.

What happens with very many degrees of freedom?

The t distribution approaches the standard normal: with 30 df the two-sided 95 % critical value is 2.042, with 1,000 df it is 1.962, close to z = 1.960.

Sources

Last updated:

More Statistics calculators

People also use