Overview

Degrees of freedom, df, are the number of values that are free to vary once some quantities are fixed. Many statistical tests need them to find the right critical values.

Enter the sample size, estimated parameters and number of groups, then a test code: 1 general (n − parameters), 2 chi-square goodness of fit (groups − 1), 3 one-sample t (n − 1) or 4 ANOVA within-groups (n − groups).

Worked examples

InputsResult
Sample Size (n)120Estimated Parameters4Number of Groups3TestGeneralDegrees of freedom (general): 116Inputs n=120, parameters=4, groups=3
Show 3 more examples
Sample Size (n)30Estimated Parameters1Number of Groups1Testt-testDegrees of freedom (one-sample t): 29Inputs n=30, parameters=1, groups=1
Sample Size (n)60Estimated Parameters1Number of Groups4TestANOVADegrees of freedom (ANOVA within-groups): 56Inputs n=60, parameters=1, groups=4
Sample Size (n)200Estimated Parameters1Number of Groups6TestChi-squareDegrees of freedom (chi-square goodness-of-fit): 5Inputs n=200, parameters=1, groups=6

Degrees of freedom (general) by sample size

With the calculator's starting values, the degrees of freedom (general) is 116. The table shows how it changes with the sample size.

Sample Size (n)Degrees of freedom (general)
6056
8076
10096
120starting value116
140136
160156
180176

Other inputs: Estimated Parameters: 4 · Number of Groups: 3. Change them in the calculator above for your own numbers.

How it works

Each estimated quantity uses up one degree of freedom. A one-sample t-test estimates the mean, so df = n − 1. A goodness-of-fit test with k categories has k − 1. ANOVA's within-groups df is n − k. Regression residual df is n − the number of estimated coefficients.

Practical tips

  • 120 observations with 4 estimated parameters gives 116 general df.
  • A chi-square test of independence for an r × c table uses (r − 1)(c − 1).
  • A two-sample t-test with equal variances uses n₁ + n₂ − 2.

Frequently asked questions

Why does df matter?

It sets the shape of the t, chi-square and F distributions, and so the critical values.

What's df for a contingency table?

(rows − 1) × (columns − 1).

What if df is less than 1?

The test can't be run. You need more data or fewer parameters.