Degrees of Freedom Calculator

Calculate degrees of freedom for t-tests, chi-square tables, one-way ANOVA, and multiple linear regression with the correct formula.

Find degrees of freedom
Choose a statistical test, enter its sample dimensions, and calculate the available independent information.

About degrees of freedom

Degrees of freedom describe how many independent pieces of information remain after accounting for constraints or estimated parameters. They determine the shape of many reference distributions used in hypothesis tests and confidence intervals. Although the phrase can sound abstract, the basic idea is practical: once some values are fixed by a condition, the remaining values are free to vary. For a one-sample t-test, estimating the sample mean imposes one constraint, so n observations provide n - 1 degrees of freedom. A paired t-test applies the same rule to the number of paired differences. The pooled two-sample t-test estimates two group means and combines variance information, giving n₁ + n₂ - 2. Welch's unequal-variance t-test uses a more complicated approximate formula and is not represented by the pooled option in this calculator. For a chi-square contingency table, the row and column totals constrain the cell counts. Once counts in (r - 1)(c - 1) cells are known, the remaining cells follow from those margins, so df = (r - 1)(c - 1). A one-way ANOVA separates degrees of freedom into between-groups and within-groups components. With k groups and N total observations, the between-groups value is k - 1 and the within-groups value is N - k. Their sum is the total N - 1. Multiple linear regression with n observations and p predictor variables estimates p slopes plus one intercept. The residual degrees of freedom are therefore n - p - 1. This value controls the denominator used to estimate residual variance and must be positive. Models with too many predictors relative to observations have little or no remaining information for estimating error, even if software can produce fitted values. Choose the option that exactly matches the method used in your analysis. Degrees of freedom are not interchangeable across tests, and special designs can require different calculations. Repeated-measures models, Welch tests, mixed models, corrected chi-square procedures, and regressions with penalties or complex survey weights may use adjusted or approximate values. The calculator covers common textbook formulas for independent observations. Report the test statistic together with its degrees of freedom, p-value, effect size, and assumptions so readers can understand how the inference was formed.

Degrees of freedom examples

Test and inputDegrees of freedomCalculation
One-sample t-test, n = 25df = 24Subtract one estimated mean from the sample size.
Chi-square table, 4 rows by 3 columnsdf = 6(4 - 1)(3 - 1) = 6.
One-way ANOVA, 4 groups and 40 observationsBetween = 3; within = 36Use k - 1 and N - k for the two components.

How to calculate degrees of freedom

  1. Select the statistical test that matches your planned analysis.
  2. Enter the requested sample size, table dimensions, group count, or predictor count.
  3. Select Calculate degrees of freedom to apply the formula for that test.
  4. Use the result with the correct statistical reference distribution or report it beside the test statistic.

Degrees of freedom FAQ

Why do we subtract one from a sample size?

Estimating the sample mean creates one constraint because deviations from that mean must sum to zero. Once n - 1 deviations are known, the final deviation is determined.

Can degrees of freedom be a decimal?

The common formulas in this calculator produce whole numbers. Approximate procedures such as the Welch-Satterthwaite equation can produce fractional degrees of freedom.

Which t-test option should I use for unequal variances?

Do not use the pooled two-sample formula when the analysis uses Welch's t-test. Welch's method calculates an approximate df from both sample variances and sizes.

What are ANOVA within-group degrees of freedom?

Within-group degrees of freedom measure information available for estimating unexplained variation inside groups. For one-way ANOVA, the value is total observations minus the number of groups.

Why must regression residual df be positive?

Residual variation can only be estimated when observations remain after fitting every slope and the intercept. A nonpositive value indicates that the model has too many parameters for the available data.