Topic contents

Lesson 6

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
01020304010.0115.0220.0325.0430.05
  • Freely chosen first four numbers
  • Constrained number 5
Five values: choose the first four freely (drag the bars or use ↑ ↓ to adjust them); the fifth is determined by the fixed sum of 100
x5=100−(10+15+20+25)=30.00x_{5}=100-\left(10+15+20+25\right)=30.00

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

  1. 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
51015Sample mean 11.00−4.0x1=7−2.0x2=9+0.0x3=11+1.0x4=12+5.0x5=16
  • Observed values
  • Sample mean 11.00
  • Deviations (signed)
Five observations, the sample mean line, and each deviation xᵢ − x̄
s2=∑(xi−xˉ)2n−1=46.004=11.500s^{2}=\frac{\sum\left(x_{i}-\bar{x}\right)^{2}}{n-1}=\frac{46.00}{4}=11.500

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

  1. 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

Distribution type

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
−4−2024t−2.7762.7762.5%2.5%
  • t(4) distribution
  • Standard normal distribution
  • Central 95%
  • Two-sided 95% critical values
t(4) distribution (solid) and standard normal distribution (dashed)

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?

(n−1)s2σ2∼χ2(n−1)\frac{(n-1)s^{2}}{\sigma^{2}}\sim\chi^{2}(n-1)

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

Choose a setting

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
221Between k−1Within n−k
Degrees of freedom decomposition: total n−1
Between groups (k−1)+Within groups (n−k)=Total (n−1) ⁣:2+21=23\text{Between groups}\ (k-1)+\text{Within groups}\ (n-k)=\text{Total}\ (n-1)\colon\quad 2+21=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.