Degrees of freedom (df) is a statistical concept that represents the number of independent pieces of information available to estimate a parameter or test a hypothesis. It essentially quantifies how many values in a dataset can freely vary once certain constraints (like a calculated statistic) are applied. Here's a breakdown of the key ideas:
Core Concept
Degrees of freedom are calculated as the sample size minus the number of restrictions (usually parameters being estimated). For example:
Sample mean: If you calculate the mean of a dataset, one value becomes constrained (since the mean is fixed). Thus, df = n − 1 for a sample of size n[1][5][7].
Regression models: Each estimated parameter (e.g., slope, intercept) reduces the degrees of freedom[1][7].
Why It Matters
Statistical tests: Degrees of freedom determine the shape of distributions (e.g., t-distribution, chi-square) used to calculate p-values and critical values[3][7].
Model complexity: Higher df often corresponds to more flexibility in a model, but too many can lead to overfitting[2][7].
Key Analogies
Restaurant bill:
If three friends pay with specific cards (Visa, Mastercard, Discover), the fourth card must be yours (AmEx). Here, df = 3 (choices) before the final card is determined[3].
Weekly work hours:
If you must work exactly 40 hours/week, you can freely choose hours for 6 days, but the 7th day is constrained. df = 6[2].
Data with a fixed mean:
For a dataset of 7 numbers with a mean of 5, once 6 values are chosen, the 7th is fixed. df = 6[2][7].
Formula
The general formula is:
[
\text{df} = n - r
]
Where:
( n ) = sample size
( r ) = number of restrictions (e.g., estimated parameters)[1][5].
Accuracy: Higher df (larger samples) provide more reliable estimates and narrower confidence intervals[7].
Hypothesis testing: Critical values for rejecting the null hypothesis depend on df (e.g., t-tables use df to adjust for sample size)[5][7].
In essence, degrees of freedom act as a "budget" for variability in your data, balancing the trade-off between model complexity and reliable inference.