Degrees of freedom: why keep subtracting 1?
From a fixed sum to sample variance, then to t and χ² distributions, analysis of variance (ANOVA), and regression
With a fixed sum, how many numbers can vary freely?
The five numbers below must always sum to 100. Change the first four and observe what happens to the fifth.
- Number of values
- 5
- Independent constraints
- 1
- Degrees of freedom
- 4
Key observation
Choose the first four numbers separately; the fifth cannot be chosen freely, or the sum would no longer be 100. 5 numbers − 1 independent constraint = 4 degrees of freedom. This is just an intuitive starting point for understanding degrees of freedom.
Think about it
- If there were 10 numbers with a fixed sum, how many degrees of freedom would there be? What if the sum were unrestricted?
Why use n−1 when calculating sample variance?
Adjust 5 sample observations and observe the sample mean, deviations, and sum of deviations. The sample mean is calculated from these 5 numbers.
- Sample mean x̄
- 11.00
- Sum of deviations
- 0.00000000
- Residual degrees of freedom
- 4
- Observed values
- Sample mean 11.00
- Deviations (signed)
The deviations in this sample are −4.00, −2.00, 0.00, 1.00, 5.00. Their sum is always 0, so knowing the first 4 deviations determines the fifth. Here, n−1 arises from a linear constraint imposed by using the sample mean. Dividing by n−1 makes the sample variance an unbiased estimator of the population variance under independent and identically distributed sampling.
Think about it
- Why does the sample variance use n−1 rather than n as its denominator? What changes if the population mean μ is known in advance and deviations are calculated directly from μ?
Distribution settings
Try it
Compare the t distribution (solid) with the standard normal distribution (dashed) and observe the tails.
How do degrees of freedom change t and χ² distributions?
- Degrees of freedom ν
- 4
- Two-sided 95% critical value |t|
- 2.7764
- Distribution features
- Much heavier tails
- t(4) distribution
- Standard normal distribution
- Central 95%
- Two-sided 95% critical values
Solid line: t(4) distribution; dashed line: standard normal distribution. The t distribution is always symmetric, but with fewer degrees of freedom its tails are heavier and its 95% critical value is larger. As degrees of freedom increase, it approaches the standard normal distribution.
Why n−1 here too?
Under independent random sampling from a normal population, the χ² statistic associated with sample variance has n−1 degrees of freedom. When the population standard deviation is unknown, the t statistic for the mean uses the same sample variance estimate, so its t distribution also has n−1 degrees of freedom.
Model settings
Try it
Degrees of freedom beyond n−1: analysis of variance and regression
- Between-group degrees of freedom
- 2
- Within-group degrees of freedom
- 21
- Total degrees of freedom
- 23
In one-way analysis of variance (ANOVA), between-group comparisons have k−1 degrees of freedom. Estimating one mean per group leaves a total of n−k within-group residual degrees of freedom. The total deviations have n−1 degrees of freedom.
Connect the four settings
Degrees of freedom describe how many directions of independent variation remain after accounting for independent constraints imposed by the model or dimensions of information used by estimated parameters. For common linear models of full rank, residual degrees of freedom equal observations minus independently estimated parameters. We do not mechanically subtract 1 in every statistical problem.