Degrees Of Freedom - df for t, Chi-Square, ANOVA, Regression

Degrees of freedom calculator picks the right df formula for t-tests, chi-square tests, ANOVA, and regression and explains what the result means.

Degrees Of Freedom

Pick the test whose degrees of freedom you need. The other inputs appear after selection.

Used for one-sample and paired t-tests, ANOVA total N, and the simple regression n.

Sample size of the first group for two-sample t-tests and Welch's approximation.

Sample size of the second group for two-sample t-tests and Welch's approximation.

Sample standard deviation of the first group, required only for Welch's t-test.

Sample standard deviation of the second group, required only for Welch's t-test.

Categories for chi-square goodness-of-fit or groups for one-way ANOVA.

Number of rows in the contingency table for chi-square independence.

Number of columns in the contingency table for chi-square independence.

Number of predictor variables (slopes) in the regression model.

Results

Degrees of freedom (df)
0
df between groups 0
df within groups 0
df total 0
Formula used 0
Interpretation 0

What Is the Degrees of Freedom Calculator?

The degrees of freedom calculator finds the df value that the t, chi-square, F, and regression distributions need for any common hypothesis test. Pick the test family, type in the sample sizes, group counts, or predictors, and the calculator returns the exact df plus the formula and a plain-language interpretation.

  • Homework and exam prep: Quickly verify the df for t-tests, chi-square tests, ANOVA, and regression problems before plugging it into a t-table or statistical software.
  • T-test writing: Compute df for one-sample, pooled two-sample, Welch, and paired t-tests in one place instead of switching between formulas.
  • Chi-square planning: Confirm chi-square goodness-of-fit df = k - 1 or independence df = (r - 1)(c - 1) before running the test on a contingency table.
  • ANOVA and regression: Pull between, within, and total df for ANOVA, plus regression df = n - k - 1, so you can build the F-statistic and the residual degrees of freedom.

The same calculator works for nine common statistical tests, so you do not need to memorize nine different df formulas.

When you have the df from this calculator and want the matching t-statistic and p-value, the t-test calculator does the next step for one-sample, two-sample, and paired designs.

How the Degrees of Freedom Calculator Works

df depends on the test: n - 1, n1 + n2 - 2, Welch-Satterthwaite, k - 1, (r - 1)(c - 1), k - 1 / N - k, n - k - 1
  • n: Sample size for one-sample, paired t-tests, ANOVA total N, and regression.
  • n1, n2: Sample sizes for the two groups in pooled and Welch t-tests.
  • s1, s2: Sample standard deviations used only in the Welch-Satterthwaite approximation.
  • k: Number of categories for chi-square goodness-of-fit or groups for ANOVA.
  • r, c: Rows and columns of a contingency table for chi-square independence.
  • predictors: Number of slope parameters in a multiple regression model (k).

Pick the test you are running, enter the inputs the test needs, and the calculator chooses the matching df formula. The formula is shown next to the result so you can verify the arithmetic on your homework or paper.

Worked example: one-sample t-test, n = 25

Test = one-sample t-test, n = 25

df = n - 1 = 25 - 1 = 24

Degrees of freedom = 24

Look up t-critical at 24 df on a t-table or feed df = 24 to your t-distribution function.

Worked example: chi-square independence, 3 by 4 table

Test = chi-square independence, rows = 3, cols = 4

df = (r - 1)(c - 1) = (3 - 1)(4 - 1) = 2 x 3 = 6

Degrees of freedom = 6

A 3 by 4 table loses one df per row and column for the marginal totals, so 6 cells remain independent.

Worked example: one-way ANOVA, 4 groups, N = 40

Test = one-way ANOVA, k = 4 groups, N = 40

df_between = k - 1 = 3; df_within = N - k = 36; df_total = N - 1 = 39

df between = 3, df within = 36, df total = 39

These three df values go into the ANOVA F-statistic and into the F-distribution lookup.

According to Penn State STAT 200 Lesson 2.2 on Degrees of Freedom, the degrees of freedom for a one-sample t-test equal n - 1, for a two-sample pooled t-test equal n1 + n2 - 2, for a paired t-test equal n - 1, and for a chi-square test of independence equal (r - 1)(c - 1).

When you have the df from a chi-square goodness-of-fit or independence test, the chi-square calculator takes the same observed and expected frequencies and returns the chi-square statistic and p-value.

Key Concepts Explained

Four ideas come up every time you read a textbook formula for degrees of freedom. Skim them so the result from this degrees of freedom calculator makes sense in context.

Independence and constraints

Each estimated parameter removes one piece of independence from the sample. The remaining independent pieces are the degrees of freedom, which is why the formula always subtracts the number of parameters from the data count.

Why n minus 1 appears

When you compute a sample mean, all n observations are forced to add up to n times the mean. That constraint removes one piece of freedom, so a one-sample t-test always returns df = n - 1.

Two-sample df variants

The pooled t-test assumes equal variances and uses df = n1 + n2 - 2. Welch's t-test relaxes that assumption and uses the Welch-Satterthwaite approximation, which usually returns a non-integer df.

Regression df = n - k - 1

A regression with k predictors estimates one intercept plus k slopes, costing k + 1 degrees of freedom. The remaining residual df = n - k - 1 is what the F-statistic for overall regression significance uses.

Once you know the between, within, and total df from this calculator, the ANOVA calculator builds the F-statistic and p-value for one-way analysis of variance.

How to Use This Calculator

Plugging in a test and its sample counts takes about a minute. Follow the steps below and the calculator will keep live-updating the df and the formula.

  1. 1 Pick the test: Choose the statistical test whose degrees of freedom you need. Defaults load the one-sample t-test, but every test family is in the dropdown.
  2. 2 Enter sample sizes: Type in n for one-sample, paired, ANOVA, or regression tests. For two-sample t-tests fill in n1 and n2; for Welch also add s1 and s2.
  3. 3 Add test-specific inputs: For chi-square goodness-of-fit, type the category count k. For independence, type the rows and columns of your contingency table. For multiple regression, type the number of predictors.
  4. 4 Read df and the formula: The primary result is the integer df (or Welch's decimal value), and the formula line shows the arithmetic so you can match it against your textbook.
  5. 5 Use the interpretation line: The interpretation line converts the df into a sentence describing what the value means for the chosen test, useful for the methods section of a paper.
  6. 6 Reset and try another test: Click Reset to restore the one-sample defaults and switch to a different test family without reloading the page.

For a chi-square test of independence on a 2 by 3 contingency table, pick chi-square independence, type rows = 2 and cols = 3, and the calculator returns df = (2 - 1)(3 - 1) = 2 with the formula shown below.

When you only need a z-statistic for a known population standard deviation, the z-score calculator returns the standardized score and the matching normal-distribution probability without needing df at all.

Benefits of Using This Calculator

Memorizing nine df formulas is one of the biggest drags on intro stats homework. This calculator replaces the formula sheet for the most common tests.

  • Nine tests in one place: One-sample, pooled, Welch, paired, chi-square goodness-of-fit, chi-square independence, ANOVA, simple regression, and multiple regression share a single calculator.
  • Live formula display: The formula line updates with every change so you can read off the exact arithmetic instead of second-guessing the result.
  • Plain-language interpretation: Every result comes with a one-sentence interpretation so you know why the df value matters for the test you picked.
  • Welch handling built in: Welch's t-test returns a non-integer df from the Welch-Satterthwaite approximation, and the calculator rounds to two decimal places.
  • Edge-case protection: Underdetermined regression, n = 1 sample sizes, and 1 by k tables are caught with a clear error message instead of a nonsense df.
  • Free with no signup: Everything runs in the browser, so the calculator works on a phone during lab or in a quiet study hall.

When the Welch df depends on the sample standard deviations, the standard deviation calculator gives you s1 and s2 from a raw dataset so the df calculation can finish without a separate statistics package.

Factors That Affect Your Results

A handful of structural choices change the df value. Knowing these factors lets you read the result with the right level of skepticism.

Test selection

Different tests eat different numbers of degrees of freedom. The same n = 30 data set gives df = 29 for a one-sample t-test, df = 30 for a chi-square goodness-of-fit with two categories of 15 each, and df = 27 for a multiple regression with three predictors.

Equal vs unequal variances

Pooled two-sample t-tests give an integer df, while Welch's approximation usually returns a decimal. Pick Welch whenever the two sample SDs differ by more than a factor of two.

Sample size ratio

Two-sample df is larger when n1 and n2 are balanced. If n1 = 5 and n2 = 95 you still get df = 98, but the smaller group limits how precisely the mean difference can be estimated.

Number of predictors

Every additional predictor in multiple regression costs one df. Switching from simple to multiple regression with two predictors drops df from n - 2 to n - 3, which tightens the F-test.

Contingency table shape

Independence df scales with (r - 1)(c - 1). A 2 by 2 table gives df = 1, a 4 by 5 table gives df = 12, and a 6 by 6 table gives df = 25 even though both tables have the same total number of cells.

  • The calculator only returns df, not the test statistic or p-value. You still need the t, chi-square, or F statistic from your data to use the df in a hypothesis test.
  • Welch-Satterthwaite df is an approximation. For very small samples with extreme variance ratios it can overstate the df, so simulations or Satterthwaite's exact tables are safer.
  • Repeated-measures ANOVA and mixed-effects models use different df formulas that depend on the correlation structure, which this calculator does not cover.

As published by Penn State STAT 200 Lesson 12.3 on Simple Linear Regression, the residual degrees of freedom for a simple linear regression equal n - 2 because the model estimates one intercept and one slope, so each estimated coefficient removes one degree of freedom from the sample.

degrees of freedom calculator showing df formulas for one-sample, two-sample, and paired t-tests, chi-square, ANOVA, and regression with a worked example of df = 24 for n = 25
degrees of freedom calculator showing df formulas for one-sample, two-sample, and paired t-tests, chi-square, ANOVA, and regression with a worked example of df = 24 for n = 25

Frequently Asked Questions

Q: What is degrees of freedom in statistics?

A: Degrees of freedom (df) count the number of independent pieces of information left in a sample after you estimate parameters. Each estimated parameter removes one piece of independence, so df equals the sample count minus the number of parameters.

Q: How do you calculate degrees of freedom for a t-test?

A: For a one-sample or paired t-test df = n - 1. For a pooled two-sample t-test df = n1 + n2 - 2. For Welch's t-test, which assumes unequal variances, df comes from the Welch-Satterthwaite approximation and is usually a non-integer.

Q: How do you calculate degrees of freedom for a chi-square test?

A: For chi-square goodness-of-fit df = k - 1, where k is the number of categories. For chi-square test of independence on an r by c contingency table, df = (r - 1)(c - 1).

Q: How do you calculate degrees of freedom for ANOVA?

A: For one-way ANOVA with k groups and N total observations, df between groups = k - 1, df within groups = N - k, and df total = N - 1. These three values go straight into the F-statistic.

Q: How do you calculate degrees of freedom for regression?

A: For a regression model with one intercept and k slope coefficients, df = n - k - 1. Simple linear regression is the special case where k = 1, so df = n - 2.

Q: Why do we subtract 1 from sample size for degrees of freedom?

A: The sample mean forces all n observations to add up to n times the mean. That single constraint uses up one degree of freedom, which is why every formula that estimates one mean starts from n - 1.