🏆 US-Registered Digital Marketing Agency
Advertisement
Advertisement
STATISTICS

Degrees of Freedom Calculator — every common test

Degrees of freedom for one-sample, paired, pooled and Welch t-tests, chi-square, ANOVA, regression and the F-test for two variances.

A paired t-test uses the differences, so it counts as one sample of n pairs.
Number of observations, or number of pairs for a paired test.
Observations in group one.
Observations in group two.
Standard deviation of group one. Welch needs both.
Standard deviation of group two.
Treatment groups for ANOVA, outcome categories for goodness of fit.
Everything across all groups combined.
Predictors in a regression, or parameters estimated from the data before a goodness-of-fit test.
Categories of the first variable.
Categories of the second variable.
Degrees of freedom
0
 
0
Observations used
0
Constraints imposed
0
Total df
Formula applied
Tip: degrees of freedom is not a property of your data alone. It is the number of observations minus the number of quantities you had to estimate from those same observations before the test could run.
Advertisement

The degrees of freedom calculator above returns df for the eight tests that account for nearly all routine analysis, and — more usefully — names the formula it applied and shows how many constraints your design imposed. Degrees of freedom is not one rule with exceptions. It is a single idea, the number of values still free to vary once the estimates have been fixed, applied to designs that fix different numbers of things.

Arb Digital publishes free calculators that explain the number rather than just producing it. Degrees of freedom is worth that treatment because so many people learn it as "n minus one" and then meet a chi-square table, a Welch test or an ANOVA and have no way to work out which n and which one. This page covers the whole set and, for the Welch case, does an approximation that is genuinely unpleasant to compute by hand.

What This Degrees of Freedom Calculator Does

It maps a test design onto the correct df formula and evaluates it. For simple designs that is arithmetic you could do in your head; the value here is in getting the right formula rather than in the sum. For the Welch-Satterthwaite approximation it is real computation, because that df depends on the two sample standard deviations as well as the two sample sizes, and it is almost never a whole number.

Once you have df, our critical value calculator converts it into the cut-off for your chosen significance level, and our p-value calculator converts a test statistic and df into a probability. This page is the step before both of those, and it is the step most often taken on autopilot.

How to Use It

  1. Identify the test, not the data. Two columns of numbers could be an independent two-sample test or a paired test, and those have completely different df. Pairing is a property of how the data were collected.
  2. Enter the sizes the design calls for. The fields change with the test, so you are only ever asked for what that formula needs.
  3. For Welch, supply the two standard deviations. They are inputs to the df itself, not just to the test statistic, which is what makes this case different from every other one here.
  4. Count estimated parameters honestly. If you fitted a Poisson rate to your own data before testing goodness of fit against it, that is one parameter and it costs one degree of freedom.
  5. Read the formula cell. It states exactly which rule was applied, so you can quote it in a write-up or check it against a textbook.

The Formulas, Test by Test

A one-sample t-test has df = n − 1. A paired t-test is the same formula on the n differences. A two-sample t-test with pooled variance has df = n₁ + n₂ − 2, because a mean is estimated in each group. The Welch version replaces that with the Satterthwaite approximation, df = (s₁²/n₁ + s₂²/n₂)² ÷ [(s₁²/n₁)²/(n₁−1) + (s₂²/n₂)²/(n₂−1)], which the NIST/SEMATECH page on the two-sample t-test for equal means sets out alongside the pooled form.

A chi-square goodness-of-fit test has df = k − 1 − p for k categories with p parameters estimated from the data. A chi-square test of independence on an r by c table has df = (r − 1)(c − 1). One-way ANOVA has two: k − 1 between groups and N − k within, and the NIST handbook's ANOVA table section gives both as DFT and DFE. Multiple regression with p predictors and an intercept has df = n − p − 1 for the residuals. An F-test comparing two variances has n₁ − 1 in the numerator and n₂ − 1 in the denominator.

Advertisement

Why df Differs Between Tests

The single idea underneath all of those formulas is this: degrees of freedom counts the pieces of information available to estimate variability, after subtracting the pieces already spent estimating something else. Every quantity you estimate from the sample and then use inside the test costs one.

The one-sample case makes it concrete. To compute a sample variance you first need the sample mean, and you compute that mean from the same n numbers. Once the mean is fixed, only n − 1 of the deviations from it can vary freely — the last one is forced, because the deviations must sum to zero. Knowing four of five deviations from a known mean tells you the fifth exactly. So there are n − 1 independent pieces of information about spread, not n, and dividing the sum of squares by n − 1 rather than n is what makes the variance estimate unbiased.

Everything else follows the same accounting. A pooled two-sample test estimates two means, so it spends two. A regression with three predictors and an intercept estimates four coefficients, so it spends four and leaves n − 4 residual degrees of freedom. A chi-square goodness-of-fit test spends one on the constraint that the expected counts must total the observed count, plus one for each distribution parameter estimated from the data. There is no separate rule to memorise, only a count of what was estimated. Our variance calculator shows the n − 1 divisor at work directly.

Why the Chi-Square Table Rule Is (r − 1)(c − 1)

An r by c contingency table has rc cells, so the obvious guess is rc − 1 degrees of freedom. That is the right answer for a different question. The independence test does not compare your table against a fully specified set of expected counts; it compares it against expectations built from your own row and column totals.

Those totals are estimates, and they cost. You spend r − 1 degrees of freedom fixing the row proportions and c − 1 fixing the column proportions, plus one on the grand total. Subtract all of that from rc − 1 and you are left with exactly (r − 1)(c − 1). A concrete way to see it: fill in any (r − 1) by (c − 1) block of the table freely, and every remaining cell is forced by the margins. For a 3 by 4 table that is a 2 by 3 block, so df = 6. Our chi-square calculator runs the test itself once you have that number.

Welch's df, and Why It Is Not a Whole Number

The Welch-Satterthwaite formula produces a fractional df, which surprises people who expect a count of something. It is not counting; it is matching. The exact distribution of the Welch statistic is not a t-distribution at all, so the method finds the t-distribution whose variance best approximates it, and the parameter that achieves that match is generally fractional.

Work through an example. With n₁ = 10, s₁ = 5, n₂ = 12 and s₂ = 9, the two variance-over-n terms are 25/10 = 2.5 and 81/12 = 6.75. The numerator is (2.5 + 6.75)² = 85.5625. The denominator is 2.5²/9 + 6.75²/11 = 0.6944 + 4.1420 = 4.8365. Dividing gives df = 17.6910, well below the pooled answer of 20. That reduction is the price of not assuming equal variances, and it is exactly the point: when one group is far more variable than the other, the effective information is less than the raw sample sizes suggest.

The df always lands between the smaller of n₁ − 1 and n₂ − 1 and their sum, and it approaches the pooled value as the two standard deviations converge. Because the penalty is usually small and the protection against unequal variances is real, Welch is now the default two-sample t-test in most statistical software. If you do want the pooled route, our pooled standard deviation calculator computes the combined estimate, and our t-test calculator runs either version.

Regression: Why Each Predictor Costs You

In multiple regression the residual degrees of freedom is n − p − 1, so every predictor added spends one more. This is the arithmetic behind overfitting. With ten observations and nine predictors plus an intercept you have zero residual degrees of freedom, the model fits perfectly, and it has told you nothing — there is no information left over to check it against.

It is also why adjusted R-squared exists. Plain R-squared can only rise when you add a predictor, however useless. Adjusted R-squared divides by the residual degrees of freedom, so it falls when a new predictor does not earn the df it consumed. Any time a model summary shows R-squared climbing while adjusted R-squared falls, the model is spending degrees of freedom on noise. Our linear regression calculator reports both.

Running experiments on real campaigns?

Arb Digital designs tests with enough data to answer the question, and reports results with the assumptions stated rather than buried.

Browse All Free Tools Talk To Our Team

Common Mistakes to Avoid

  • Using n − 1 on a two-sample test — an independent two-sample test spends a degree of freedom on each group's mean, giving n₁ + n₂ − 2.
  • Treating a paired design as independent — a paired test has n − 1 df on the n differences, roughly half what an independent test on the same rows would claim.
  • Using rc − 1 for a contingency table — the row and column totals are estimated from the data, which is what reduces it to (r − 1)(c − 1).
  • Rounding Welch's df to a whole number — it is a matching parameter, not a count, and most software uses the fractional value directly.
  • Forgetting parameters estimated before a goodness-of-fit test — fitting a distribution to the same data you then test against costs one degree of freedom per fitted parameter.

Related Free Tools From Arb Digital

Run the test itself with the t-test calculator, compare three or more group means with the ANOVA calculator, test a contingency table with the chi-square calculator, find the cut-off for your alpha with the critical value calculator, or turn a statistic into a probability with the p-value calculator. The full free online tools hub lists every statistics tool we publish.

Frequently Asked Questions

What are degrees of freedom in statistics?

They are the number of values in a calculation that are free to vary once the quantities estimated from the same data have been fixed. Each estimated parameter removes one degree of freedom.

Why is it n minus 1 and not n?

Because the sample mean is computed from the same observations, and once it is fixed the deviations from it must sum to zero. That forces the last deviation, leaving n minus 1 independent pieces of information about spread.

What are the degrees of freedom for a two-sample t-test?

For the pooled version it is n1 plus n2 minus 2, because a mean is estimated in each group. For the Welch version it comes from the Satterthwaite approximation and depends on the two standard deviations as well as the sizes.

Why is Welch's df not a whole number?

It is not a count of anything. It is the parameter of the t-distribution that best approximates the true distribution of the Welch statistic, and the best match is usually fractional.

How do I find df for a chi-square test of independence?

Multiply one less than the number of rows by one less than the number of columns. A three by four table has two times three, which is six degrees of freedom.

Does ANOVA have one set of degrees of freedom or two?

Two. The between-groups df is the number of groups minus one, and the within-groups df is the total sample size minus the number of groups. The F statistic needs both.

What happens as degrees of freedom get large?

The t-distribution converges on the standard normal. By about thirty degrees of freedom the difference in critical values is small, and beyond a hundred it is negligible for most purposes.

Can degrees of freedom be zero or negative?

Zero means you have estimated as many parameters as you have observations, so nothing is left to test with. A negative result means the design is impossible as described and an input is wrong.

Advertisement
Advertisement

Take it further