Lelifi·tools

Degrees of Freedom Calculator

Degrees of freedom count the values in a calculation that are free to vary. A one sample t test on 25 observations has 25 - 1 = 24 df, so the 5% critical value is 2.064. A 3 by 4 chi square table has 6 df, and 4 groups of 60 cases have 3 and 56.

Pick your test, enter the sample sizes and spreads, and get the degrees of freedom for t tests, chi square, ANOVA or regression, with the critical value that goes with it.

By the Lelifi editors ·

Key takeaways

Where the 24 degrees of freedom come from25 bag weights, one estimated meandf = n - 1 = 25 - 1 = 24critical t at 5% = 2.064Read row 24, not row 25.
The estimated mean spends one degree of freedom, so 25 bags are judged on 24.
59 total df across 4 groups of 60 caseswithin groups: 56 dfBetween groups (3)Within groups (56)
ANOVA splits 59 total df into 3 between groups and 56 within, and the two parts must add back to 59.
On this page
  1. Degrees of freedom, in plain words
  2. The formula for each test
  3. Worked example: 25 bags off the line
  4. Welch's correction when the spreads differ
  5. Degrees of freedom in ANOVA and regression
  6. Why df changes your critical value
  7. Four mistakes to avoid

Degrees of freedom, in plain words

Degrees of freedom, usually written df, count how many values in a calculation are free to change once a constraint is fixed. Take five numbers with a mean of 10. You can pick four of them freely, say 8, 9, 11 and 12, but the fifth is forced: it has to be 10 for the mean to hold. Five values, one constraint, so 4 degrees of freedom.

That is the whole idea. Every statistic that estimates something from your data spends one degree of freedom. Estimate a mean from n observations and you have n - 1 left. Estimate a pooled variance from two samples and you spend two, leaving n1 + n2 - 2.

The count matters because test statistics are compared against distributions that change shape with df. A t statistic of 2.06 is borderline at 24 df and ordinary at 200 df, so the same number can lead two analysts to different conclusions if they read the wrong row.

The formula for each test

Each test spends degrees of freedom in its own way. The table below collects the formulas this calculator uses. The pattern to remember: subtract one for every mean or parameter you estimate from the data.

TestDegrees of freedomExample
One sample t testn - 125 observations: 24
Two sample t test, pooledn1 + n2 - 225 and 31: 54
Welch two sample t testWelch Satterthwaite, see below12 and 16 with unequal spread: 21.9
Chi square goodness of fitk - 16 categories: 5
Chi square test of independence(r - 1)(c - 1)3 rows, 4 columns: 6
One way ANOVAk - 1 between, N - k within4 groups, 60 cases: 3 and 56
Simple linear regressionn - 2 residual30 points: 28

Two rows deserve a comment. The independence formula multiplies the shortfalls on each side, so a 3 by 4 table has (3 - 1) x (4 - 1) = 6 df, not 12. Regression with p predictors uses n - p - 1, which is why the simple version with one predictor is n - 2.

Worked example: 25 bags off the line

Suppose a machine is set to fill 50 gram bags. You weigh 25 bags and get a sample mean of 52.4 grams with a standard deviation of 6.8 grams. Is the machine off target?

The statistic of 1.76 sits below 2.064, so at 24 df you would not reject the target. Run the same test with 100 bags and the picture changes. The standard error falls to 0.68, the t statistic doubles to 3.53, and df rises to 99, where the critical value is close to 1.984. Same machine, same gap from target, and the conclusion flips because more data buys both a bigger statistic and a lower hurdle.

With two independent samples of 25 and 31 bags, the pooled test has 25 + 31 - 2 = 54 df, and the critical value at 5% is 2.005. The Penn State STAT 500 notes walk through the pooling step in detail.

Welch's correction when the spreads differ

The pooled two sample formula assumes both populations share one variance. When sample standard deviations differ a lot, say 4 and 9, that assumption is shaky, and the Welch Satterthwaite correction is the safer count:

df = (s1 squared / n1 + s2 squared / n2) squared / [ (s1 squared / n1) squared / (n1 - 1) + (s2 squared / n2) squared / (n2 - 1) ]

Run it with n1 = 12, n2 = 16, s1 = 4 and s2 = 9. The two variance terms are 16 / 12 = 1.333 and 81 / 16 = 5.063, so the numerator is 6.396 squared = 40.91. The denominator is 1.333 squared / 11 + 5.063 squared / 15 = 0.162 + 1.709 = 1.871. That gives df = 40.91 / 1.871 = 21.9, against 26 for the pooled version. The correction spends about 4 df to buy protection against the unequal spread, and the critical value moves from 2.056 to 2.080 as a result.

Software reports Welch df as a decimal, and that is fine. Round down when you read a printed table, so 21.9 is read at row 21.

Degrees of freedom in ANOVA and regression

Analysis of variance splits the total df across sources. With 4 groups and 60 observations in total:

SourceFormulaValue
Between groupsk - 13
Within groupsN - k56
TotalN - 159

The three numbers must add up: 3 + 56 = 59. If your ANOVA table does not add up, a group size was entered wrong or an observation was dropped.

Simple linear regression does the same split. Fit a line to 30 points and you spend 1 df on the slope and 1 on the intercept, leaving 30 - 2 = 28 residual df. Add a second predictor and residual df drops to 27. The NIST engineering statistics handbook lists the df breakdown for fitted models and for the t and chi square distributions used to judge them.

This is also where the F test gets its two df values. In a regression with 3 predictors and 40 observations, the model is tested on 3 and 36 df, because 40 - 3 - 1 = 36.

Why df changes your critical value

The t distribution has fatter tails when df is low, because the sample standard deviation is itself an estimate. Each extra observation sharpens that estimate, and the critical value slides toward the 1.960 of the normal curve.

dfCritical t, 5% two sided
52.571
102.228
152.131
242.064
302.042
602.000
1201.980
Normal curve1.960

Read the first and last rows together: a t statistic of 2.2 clears the bar at 60 df and fails at 5 df. Degrees of freedom are not bookkeeping. They are part of the verdict.

Chi square tables move the same way, with more room. A 5 category goodness of fit test has 4 df and a critical value of 9.488 at the 5% level, while 20 df needs 31.410. Report df next to every test statistic so a reader can check the comparison without guessing.

Four mistakes to avoid

When in doubt, count constraints. Every estimated parameter subtracts one, and every margin in a contingency table subtracts one per row and one per column. The count falls out of the design, not out of the software output.

One last habit is worth the ten seconds it takes: write the df on the same line as the test statistic and the p value. A result pasted into a report without its df cannot be checked by anyone reading it later.

Frequently asked questions

What does degrees of freedom mean in statistics?

It counts how many values are free to vary once the constraints of a calculation are fixed. Five numbers with a known mean of 10 have 4 degrees of freedom, because the fifth value is forced once you know the other four.

How do you calculate df for a one sample t test?

Subtract 1 from the sample size. A test on 25 observations has df = 25 - 1 = 24, and you read the t table at row 24, where the two sided 5% critical value is 2.064.

What is the df for a two sample t test?

For the pooled version, add the two sample sizes and subtract 2. Samples of 25 and 31 give 25 + 31 - 2 = 54 df, with a critical value of 2.005 at the 5% level.

How does the Welch Satterthwaite formula work?

It weights the two variance estimates by their precision. With n1 = 12, n2 = 16, s1 = 4 and s2 = 9 it gives df = 21.9, against 26 for the pooled version.

How many degrees of freedom does a chi square goodness of fit test have?

One less than the number of categories. Testing 6 outcomes against expected proportions gives 6 - 1 = 5 df, and the 5% critical value is 11.070.

What about a chi square test of independence?

Multiply one less than the row count by one less than the column count. A 3 by 4 table has (3 - 1) x (4 - 1) = 6 df, and the 5% critical value is 12.592.

How do you find df in ANOVA?

Between groups it is k - 1, within groups it is N - k. With 4 groups and 60 observations that is 3 and 56, which add to the total of 59.

Why do we subtract 1 for the mean?

Estimating the mean uses one piece of information from the data, so only n - 1 values can still vary. The estimated mean is the constraint that spends the degree of freedom.

Can degrees of freedom be a decimal?

Yes. The Welch formula produces fractional df, and software reports values like 21.9. Round down when you use a printed table, so 21.9 is read at row 21.

What df do I use to read a t table for 25 observations?

Row 24. The two sided 5% critical value there is 2.064, which is higher than the 1.960 of the normal curve because the standard deviation is estimated from a small sample.

Is degrees of freedom the same as sample size?

No. It equals the sample size minus every parameter you estimate. A regression on 30 points with one predictor has 28 residual df, not 30.

Does more df always mean more power?

More df lowers the critical value toward 1.960 and sharpens the test, but power also depends on effect size and variance. A larger sample helps through both routes at once, which is why 100 bags settled a question that 25 could not.

Where can I see df in an ANOVA table?

In the df column next to each source of variation. Between groups, within groups and total must satisfy (k - 1) + (N - k) = N - 1, so 3 + 56 = 59 in a 4 group study of 60 cases.

Spotted a wrong number or a broken result?

More Math tools

See all Math tools

Fee schedules, rates and rules change without notice. Always confirm important figures with the official source before you rely on them.