Skip to content
Statistics

Degrees of Freedom Calculator

Choose your statistical test, enter the sample sizes (and variances for Welch's t-test), and the calculator returns the correct degrees of freedom instantly. Nine test modes are covered: one-sample t-test, two-sample t-test with equal variances, Welch's t-test for unequal variances, chi-square independence, chi-square goodness-of-fit, one-way ANOVA (between, within, and total), F-test for variance ratio, simple linear regression, and multiple linear regression. The show-your-work panel displays the exact formula and arithmetic for your inputs.

Your details

Select the test whose degrees of freedom you want to compute.
Total number of observations in the sample.
Degrees of freedom
29

The main degrees of freedom result for the selected test.

df (between groups)-
df (within groups)-
df (total)-
df (numerator)-
df (denominator)-
df (model)-
df (error / residual)-

1-sample t-test: df = 29

  • With n = 30, one degree of freedom is lost estimating the population mean from the sample mean.
  • Larger df means the t-distribution is closer to a standard normal curve, making critical values smaller.

Next stepUse this df value to look up the critical value or p-value in the appropriate distribution table (t, chi-square, or F).

What are degrees of freedom?

Degrees of freedom (df) is the number of independent pieces of information available to estimate a statistical parameter. Intuitively, when you calculate a sample mean from n values and then use that mean to estimate variance, you have already "used up" one constraint: if you know n-1 of the deviations from the mean, the last deviation is determined. That is why the sample variance divides by n-1, not n, and why the one-sample t-test has df = n-1. The idea extends naturally to more complex tests: every estimated parameter consumes one degree of freedom, and df is the count of what remains free to vary.

Which formula applies to my test?

The formula depends entirely on the test being run. For a one-sample or paired t-test, df = n - 1. For a two-sample t-test with equal variances, df = n1 + n2 - 2. For Welch's t-test with unequal variances, the Satterthwaite approximation gives a fractional df that accounts for the imbalance in variance between the two groups. For a chi-square independence test on a contingency table with r rows and c columns, df = (r-1)(c-1). For a chi-square goodness-of-fit test with k categories and m parameters estimated from the data, df = k - 1 - m. One-way ANOVA splits df into three parts: between groups (k-1), within groups (N-k), and total (N-1). An F-test for comparing two variances uses df1 = n1-1 and df2 = n2-1. Simple linear regression has df_error = n-2, and multiple regression with p predictors has df_error = n-p-1.

Why Welch's t-test gives a fractional df

When the two groups have unequal variances, the Satterthwaite (or Welch-Satterthwaite) approximation estimates the effective degrees of freedom for the pooled standard error. The formula takes the squared sum of the variance-to-n ratios as the numerator, and a weighted sum of those ratios squared as the denominator: df = (s1^2/n1 + s2^2/n2)^2 divided by [(s1^2/n1)^2/(n1-1) + (s2^2/n2)^2/(n2-1)]. The result is usually not a whole number; most software floors it to the nearest integer when looking up critical values, although some use the exact fractional value for p-value calculations. Welch's df is always less than or equal to the pooled df (n1+n2-2), because the approximation is conservative.

Degrees of freedom in ANOVA and regression

In one-way ANOVA, the total variability in the data (df_total = N-1) is partitioned into between-group variability (df_between = k-1) and within-group variability (df_within = N-k). These two df values index the F-distribution you compare your F statistic against, reported as F(df_between, df_within). In linear regression, df_model equals the number of predictors p (or 1 for simple regression), and df_error = n-p-1. The residual df controls the precision of the mean squared error estimate; very low residual df (below about 10) indicates the model may be over-parameterised relative to the data available.

Degrees of freedom formulas by test

TestFormulaPrimary df output
1-sample t-testdf = n - 1Single df value
2-sample t-test (pooled)df = n1 + n2 - 2Single df value
Welch's t-testdf = (s1^2/n1 + s2^2/n2)^2 / [...]Decimal df (round down)
Chi-square independencedf = (r-1)(c-1)Single df value
Chi-square goodness-of-fitdf = k - 1 - mSingle df value
One-way ANOVAdf_between = k-1; df_within = N-kBetween and within df
F-test (variance ratio)df1 = n1-1; df2 = n2-1Numerator and denominator df
Simple linear regressiondf_model = 1; df_error = n-2Model and residual df
Multiple linear regressiondf_model = p; df_error = n-p-1Model and residual df

Quick reference for the most common statistical tests. df = degrees of freedom, n = sample size, k = groups or categories, p = predictors.

Frequently asked questions

Why does degrees of freedom matter in statistical testing?

Degrees of freedom determine the shape of the reference distribution (t, chi-square, or F) used to calculate p-values and critical values. A higher df makes the distribution more concentrated around the center and reduces the critical value needed for significance. Using the wrong df gives incorrect p-values and can lead you to wrong conclusions about statistical significance.

What is Welch's t-test and why does it give a non-integer df?

Welch's t-test is a version of the two-sample t-test designed for groups with unequal variances. Instead of assuming a common population variance, it uses the Satterthwaite approximation to compute an effective df that accounts for the variance imbalance. The formula produces a fractional number, and most software rounds it down to the nearest integer when reading critical values from a t-table.

When should I subtract estimated parameters in the chi-square goodness-of-fit test?

Subtract m (the number of parameters estimated from the data) whenever you fit a distribution by estimating its parameters from the same sample you are testing. For example, if you test whether data follow a normal distribution and estimate both the mean and standard deviation from the data, set m = 2, giving df = k - 3. If the distribution parameters are specified in advance (not estimated), leave m = 0.

What is the difference between df_between and df_within in ANOVA?

In one-way ANOVA, df_between (= k - 1) measures variability in the group means and is the numerator df for the F-test. df_within (= N - k) measures variability within each group (error) and is the denominator df. The ratio of the two mean squares (MS_between / MS_within) is the F statistic, which you compare against the F-distribution indexed by (df_between, df_within).

How many observations do I need for reliable regression estimates?

A widely cited heuristic is at least 10 to 20 observations per predictor, so a model with 5 predictors needs 50 to 100 observations. This translates directly to df_error = n - p - 1: a residual df below 10 often signals that the error variance estimate is too uncertain for reliable inference. Larger df_error gives more stable standard errors and narrower confidence intervals.

Does degrees of freedom change if I use a one-tailed vs two-tailed test?

No. The df is determined entirely by sample sizes and test type, not by whether the test is one-tailed or two-tailed. What changes is how you use the df: for a one-tailed test you look up the critical value at alpha rather than alpha/2, but the df itself is the same.

Sources

Written by Dr. Hannah Brandt, PhD Statistician · Munich, Germany

Applied statistician translating rigorous probability theory into clear, accurate tools for researchers and practitioners.

Search 3,500+ calculators

Loading search…