What the Heck Are Degrees of Freedom, Anyway?
Info sheet · Statistics for Psychology & Neuroscience
Warning✎ Editing notes — to do / to check
Working notes for the author — not shown to students once collapsed; remove before publishing.
- [ ]
What you’ll get from this sheet
By the end you should be able to:
- Say, in one sentence, what a degree of freedom is.
- Explain why the sample variance divides by \(n-1\) instead of \(n\).
- Work out the degrees of freedom for the tests you already use.
A degree of freedom is a piece of information that is free to vary. Rule of thumb: df = (how many numbers you have) − (how many things you estimated from them).
The idea in one line
[TODO: your voice here.] Every time you estimate something from your data — a mean, a slope — you “use up” a piece of the information the data contained. Degrees of freedom count what’s left over.
Why \(n-1\)? The last value isn’t free
Suppose I tell you three numbers have a mean of 10. You can pick the first two freely — say 8 and 15 — but the third is now forced to be 7, because the mean is fixed. Three numbers, one constraint (the mean), so only two are free to vary. That is why the sample variance divides by \(n-1\): one degree of freedom was already spent estimating the mean.
Drag the sliders: green circles are free to vary; amber circles are fixed by the parameters you’ve already estimated.
Degrees of freedom in the tests you already know
| Procedure | Degrees of freedom |
|---|---|
| Sample variance / SD | \(n - 1\) |
| One-sample t-test | \(n - 1\) |
| Independent t-test | \(n_1 + n_2 - 2\) |
| One-way ANOVA | between: \(k - 1\) · within: \(N - k\) |
| Simple regression | \(n - 2\) |
| Multiple regression | \(n - p - 1\) |
The pattern is always the same: start with your n, subtract one for each quantity you had to estimate along the way.
See it in code
The sample variance divides by \(n-1\) — the software is doing the degrees-of-freedom bookkeeping for you.
x = [4 8 6 5 9 7];
var(x) % divides by n - 1 by default
numel(x) - 1 % the degrees of freedomStatic reference — the R and Python tabs run live in the page.
TipCheck your understanding
A one-way ANOVA with 4 groups and 40 observations in total. What are the between- and within-group degrees of freedom?
Between groups: \(k - 1 = 4 - 1 = \mathbf{3}\). Within groups: \(N - k = 40 - 4 = \mathbf{36}\). You’d report the test as \(F(3, 36)\).
Forgetting that every estimated parameter costs a degree of freedom. It’s why variance divides by \(n-1\) (you already spent one on the mean), and why piling predictors into a regression shrinks its residual df — eventually leaving too little information to trust the estimates.
Where this shows up next
Degrees of freedom set the shape of the t, F, and \(\chi^2\) distributions you look your test statistics up against. See the ANOVA and Regression chapters for how the df feed into the F‑ and t‑tables.
[TODO: add a worked example from your own teaching, and a link to the fuller treatment in the book.]