Goodness of Fit and Degrees of Freedom
Statement
For N data points with independent Gaussian errors, fitted to a model with M adjustable parameters by minimising χ², the minimised statistic obeys E[χ²min] = N − M and, for a linear model, is distributed as χ² with ν = N − M degrees of freedom. Each fitted parameter therefore removes exactly one degree of freedom, and the reduced statistic χ²ν = χ²min / (N − M) has expectation one, which is the working goodness-of-fit test.
Why it matters
Almost every quantitative measurement in physics ends with a fit: extracting a lifetime, a coupling constant, a slope, a resonance mass. The reduced chi-squared is the single number that tells you whether the model and the error bars are mutually consistent. Without the N − M correction you would systematically expect too large a χ² and reject perfectly good fits.
The result also encodes a deep bookkeeping principle: information "spent" constraining parameters is no longer available to test the model. Overfitting, the bias in the sample variance, the Bessel correction, and the penalty terms in AIC/BIC are all the same accounting seen from different angles.
Assumptions
Derivation
Result
Reading. A well-fitting model over N points with M free parameters should return χ²min near N − M, i.e. χ²ν ≈ 1 ± √(2/ν). Substantially larger means the model is wrong or the errors are underestimated; substantially smaller means the errors are overestimated or the model is overfitting. Each parameter you fit costs exactly one degree of freedom because fitting projects the residual out of one more dimension.
Units check. Every residual is divided by its own σi, so each term (yi − f)²/σi² is dimensionless; χ², N, M, and ν are all pure numbers, and χ²ν is a dimensionless ratio of order unity.
Limiting cases
- No parameters (M = 0): comparing data to a fully-specified model, χ²min ~ χ²N, the classic Pearson goodness-of-fit test.
- One parameter (M = 1), constant model: fitting the weighted mean gives ν = N − 1 — this is the origin of the Bessel (N − 1) correction to the sample variance.
- Saturated fit (M = N): ν = 0, χ²min = 0 exactly; the model passes through every point and χ²ν is undefined — a fit with no predictive test.
- Large ν: χ²ν → 1 with spread √(2/ν) → 0; by the CLT the distribution becomes Gaussian and even small deviations from 1 become statistically significant.
Breaks when
- Correlated errors: a non-diagonal covariance means the plain sum of squares is not the correct statistic; the residual "counts" fewer independent numbers and the naive N − M overstates the degrees of freedom. Use χ² = rᵀC−1r with the full covariance C.
- Strongly nonlinear model: the hat matrix is only a local linearisation, so χ²min is chi-squared only asymptotically; near boundaries or with few data E[χ²min] ≠ N − M and confidence regions are non-elliptical.
- Non-Gaussian / outlier-laden errors: heavy tails make χ²min systematically large and the chi-squared reference distribution invalid; a single 5σ outlier can dominate the sum.
- Wrong error scale: if all σi are off by a common factor k, then χ²ν scales by 1/k², so a value far from 1 cannot distinguish a wrong model from mis-estimated uncertainties.
- Parameters at a boundary or degenerate: if a parameter hits a physical limit or two parameters are near-degenerate, the effective count of fitted parameters drops below M and the dof accounting fails (Chernoff / boundary corrections needed).
Failure modes
- Using N instead of N − M: dividing by the number of points rather than the degrees of freedom, systematically biasing χ²ν low and passing bad fits.
- Forgetting the 1/σi² weights: summing raw squared residuals gives a dimensional quantity with no distributional meaning.
- Reading χ²ν > 1 as automatically bad: ignoring the spread √(2/ν); for small ν a value of 1.5 is entirely ordinary.
- Celebrating χ²ν ≈ 0.2: a very small reduced chi-squared is a warning of overestimated error bars or too many free parameters, not a triumph.
- Counting fixed or constrained parameters as free: a parameter held at a value, or tied to another, does not cost a full degree of freedom.
- Over-parameterising then still quoting ν = N − 1: adding nuisance parameters silently lowers χ²min but must also lower ν.
Discussion
The whole result is a statement about geometry. The N-dimensional whitened data vector is split by the fit into a component inside the M-dimensional model subspace (the fitted values) and a component in its orthogonal complement (the residual). Only the orthogonal complement, of dimension N − M, is free to fluctuate against the noise, and its squared length is what χ²min measures. Fitting a parameter is literally the act of projecting out one more direction, which is why the count is exact and integer.
This is the same bookkeeping that appears throughout statistics: the Bessel (N − 1) in the sample variance is the M = 1 case (one parameter, the mean, is estimated from the data); the residual degrees of freedom in ANOVA and ordinary regression are N − M; and the information criteria AIC and BIC add explicit 2M or M ln N penalties precisely because extra parameters buy a lower χ² that is not real predictive power. The reduced chi-squared is the physicist's minimal version of this penalty.
Practically, the test is two-sided. A large χ²ν flags an inadequate model, systematic error, or underestimated uncertainties; a small one flags overestimated uncertainties or an over-flexible model. Because it cannot by itself separate "wrong model" from "wrong error bars", it should be read alongside a residual plot: structure in the residuals (runs, trends, curvature) diagnoses model failure, while a flat but large scatter diagnoses the error scale.
The exactness χ²min ~ χ²N−M holds strictly only for models linear in their parameters with Gaussian, correctly-scaled, uncorrelated errors. For nonlinear models the guarantee is asymptotic and rests on Wilks' theorem: as data accumulate, twice the log-likelihood-ratio between the best fit and the truth converges to a χ² with degrees of freedom equal to the number of fitted parameters, regardless of the parameter values. Boundary cases (a parameter estimated at a physical edge, such as a non-negative rate pinned at zero) break the regularity conditions, and the asymptotic distribution becomes a mixture of chi-squared laws (Chernoff's theorem) rather than a single χ²N−M.
Common misconceptions. "χ²ν = 1 proves the model is correct" — no; it proves only consistency with the stated errors, and infinitely many models can be consistent. "Smaller χ²ν is always better" — false; the target is 1, not 0. "Adding a parameter that lowers χ²min improves the fit" — only if it lowers χ²ν, since ν also drops; a genuine improvement must beat the one-unit-per-parameter expectation.
Worked examples
Example 1 — weighted mean of five measurements (M = 1). Five independent readings of a resistance, all with σ = 0.20 Ω: R = {10.1, 9.7, 10.3, 9.9, 10.0} Ω. Fit the single-parameter constant model (the weighted mean).
Reading. The reduced chi-squared sits only (1.25 − 1)/0.71 ≈ 0.35 standard deviations above 1 — a completely acceptable fit; the readings are consistent with a single true resistance of 10.00 ± 0.09 Ω (standard error σ/√N).
Example 2 — straight-line fit (M = 2). Five points, all with σ = 0.20: x = {1,2,3,4,5}, y = {2.1, 3.9, 6.2, 7.8, 10.1}. Fit y = a + b x.
Reading. χ²ν = 0.89 is within 0.13 standard deviations of 1 — an excellent linear fit. Note that fitting a second parameter dropped ν from 4 to 3: the extra freedom is paid for one degree at a time, exactly as E[χ²min] = N − M predicts.
Problems
- (Easy — dof counting.) A spectrum of 20 channels is fitted with a model having 3 free parameters. State the number of degrees of freedom and the expected value and standard deviation of χ²min.
Solution
ν = N − M = 20 − 3 = 17. Then E[χ²min] = 17 and Var = 2ν = 34, so the standard deviation is √34 ≈ 5.8. A good fit would give χ²min roughly in the range 17 ± 5.8.
- (Easy/medium — reduced chi-squared.) The fit in Problem 1 returns χ²min = 25.3. Compute χ²ν and assess the fit.
Solution
χ²ν = 25.3/17 = 1.49. The spread of χ²ν is √(2/17) = 0.343, so (1.49 − 1)/0.343 = 1.43 standard deviations above 1 (equivalently χ²min is (25.3−17)/5.8 = 1.43σ high). This is marginal but acceptable — a one-sided p ≈ 0.09; not grounds to reject at the 5% level.
- (Medium — weighted mean.) Four voltage readings with unequal errors: V = {5.02 ± 0.02, 4.98 ± 0.02, 5.10 ± 0.04, 4.95 ± 0.04} V. Fit the weighted mean and compute χ²ν.
Solution
Weights wi = 1/σi²: {2500, 2500, 625, 625}, Σw = 6250. Weighted mean V̄ = ΣwiVi/Σwi. Numerator = 2500·5.02 + 2500·4.98 + 625·5.10 + 625·4.95 = 12550 + 12450 + 3187.5 + 3093.75 = 31281.25, so V̄ = 31281.25/6250 = 5.005 V. Residuals Vi−V̄ = {+0.015, −0.025, +0.095, −0.055}. Standardised squares (Vi−V̄)²/σi²: 0.000225/0.0004 = 0.5625; 0.000625/0.0004 = 1.5625; 0.009025/0.0016 = 5.641; 0.003025/0.0016 = 1.891. Sum χ²min = 9.66. With ν = 4 − 1 = 3, χ²ν = 3.22, i.e. (3.22−1)/√(2/3) = 2.7σ high — the third reading is an outlier and the four values are not mutually consistent.
- (Medium — overfitting.) Explain, using the projection picture, why fitting an (N−1)-degree polynomial to N points gives χ²min = 0, and why this is not a good fit. What is ν?
Solution
An (N−1)-degree polynomial has M = N coefficients, so the model subspace is the whole N-dimensional space. The projection H = I, the orthogonal complement has dimension N − M = 0, and the residual (I−H)n = 0 identically: the curve passes through every point, giving χ²min = 0. With ν = 0 the reduced chi-squared 0/0 is undefined. There is no residual left to test the model against, so a perfect χ² here signals zero predictive content, not a good description — the fit has simply memorised the noise.
- (Hard — significance at large ν.) A cosmology fit has ν = 100 and returns χ²min = 135. Using the Gaussian approximation to the chi-squared distribution, is the fit acceptable? Contrast with a fit that gives the same χ²ν at ν = 4.
Solution
χ²ν = 135/100 = 1.35. For large ν, χ²min is approximately Gaussian with mean ν = 100 and standard deviation √(2ν) = √200 = 14.1. So z = (135 − 100)/14.1 = 2.48, a one-sided p ≈ 0.007 — the fit is poor and would be rejected at the 1% level. At ν = 4, the same χ²ν = 1.35 means χ²min = 5.4, with spread √(2·4) = 2.83, giving z = (5.4 − 4)/2.83 = 0.49 — entirely ordinary. The identical reduced chi-squared is compelling evidence against the model at large ν but meaningless at small ν, because the fractional spread √(2/ν) shrinks as ν grows. Always quote ν alongside χ²ν.