Degrees of Freedom
A plain-English take on degrees of freedom, the count of values in a calculation that are still free to vary after you have spent some of them estimating other quantities, why the sample variance divides by n minus 1, and how the same bookkeeping shows up in t-tests and regression.
Degrees of freedom sounds abstract, but it's really a headcount: of all the numbers going into a calculation, how many are still free to be anything once you've used the data to pin down other quantities? Every quantity you estimate from the sample "uses up" one of those free slots. That single idea explains the mysterious "minus one" in the variance formula and the "minus " all over regression.
The cleanest picture: imagine five numbers whose average is required to equal some fixed value . You can pick the first four to be whatever you like, but the moment those four are set, the fifth is forced, it has to be exactly the value that makes the average come out right. So five numbers with a pinned average carry only four free choices. In symbols, degrees of freedom : you started with values and spent one on fixing the mean.
Worked example: why variance divides by n − 1
Take three numbers: . Their mean is . The deviations from the mean are , and notice they must sum to zero (that's what "mean" guarantees). So if I tell you the first two deviations, and , the third is forced to be . Only two of the three deviations are free: degrees of freedom.
Now the payoff. The sum of squared deviations is . How should we turn that into a variance?
Dividing by systematically underestimates the true variance, because the deviations are measured from the sample mean, which is itself tuned to sit as close to the data as possible, making the squared gaps a touch too small. Dividing by the degrees of freedom (Bessel's correction) exactly cancels that shrinkage and gives an unbiased estimate. The correction is largest for tiny samples and fades as grows. See Bias, Variance, and the Quality of Estimators.
For a sample, divide the summed squared deviations by , not . Dividing by biases variance, and therefore volatility, downward, and the distortion is worst exactly when the sample is small.
The same rule everywhere
The recipe generalizes: degrees of freedom = number of data points − number of parameters you estimated from them. Each estimated parameter is one constraint, one used-up slot.
The one rule to carry: df = data points − parameters estimated from the data. Every quantity you estimate spends one slot, which is why the sample variance uses and a -predictor regression leaves .
| Calculation | Values () | Parameters estimated | Degrees of freedom |
|---|---|---|---|
| Sample variance | 1 (the mean) | ||
| Two-sample -test | 2 (two means) | ||
| Simple regression | 2 (slope, intercept) | ||
| Regression with predictors | |||
| Chi-square, table | row & column totals |
In a regression (see Ordinary Least Squares (OLS)), fitting an intercept plus slopes burns slots, leaving degrees of freedom for the residuals. That leftover count is what goes into standard errors, -statistics, and the -test, which is why cramming in predictors until you're nearly out of degrees of freedom makes every test unreliable.
Common pitfalls
- Dividing variance by . For a sample (not the whole population), use . With small samples the difference is real: dividing by biases the variance, and hence the volatility, downward.
- Spending all your degrees of freedom. Fit a model with predictors and only slightly more than observations and you have almost no residual degrees of freedom left, the fit hugs the noise and looks great in-sample while predicting nothing out of sample. This is one face of Overfitting.
- Grabbing the wrong df. Different tests have different formulas (a paired -test uses , a two-sample uses , a chi-square uses ). Guessing changes your critical value and your conclusion. See Hypothesis Testing.
- Forgetting df fattens the tails. The -distribution's degrees of freedom control how heavy its tails are, few degrees of freedom means fatter tails and wider honest intervals. Treating a small-sample as a normal understates your uncertainty.
The one-line takeaway: degrees of freedom count the numbers that are still free to move after your estimates have tied the rest down, and honoring that count is what keeps variances unbiased and tests trustworthy.
Related concepts
Practice in interviews
Further reading
- Wasserman, All of Statistics (Ch. 7)
- Wooldridge, Introductory Econometrics (Appendix C)