Nested linear model (source code)

= Nested linear model

Two <linear regression> models are nested when the possible mean vectors of the smaller model form a <linear subspace> of those of the larger one. With <design matrices> $X_0,X_1$, this is $\operatorname{col}(X_0)\subseteq\operatorname{col}(X_1)$. Adding a quadratic predictor to an intercept-and-linear model is an example when both use the same observations.

<Orthogonal projection> then gives $\mathrm{RSS}_1\leq\mathrm{RSS}_0$. If $r_j=\operatorname{rank}(X_j)$, $r_1>r_0$, and $n>r_1$, <independent> errors with a <normal distribution> and common positive <variance> yield
$$
F=\frac{(\mathrm{RSS}_0-\mathrm{RSS}_1)/(r_1-r_0)}{\mathrm{RSS}_1/(n-r_1)}\sim F_{r_1-r_0,n-r_1}
$$
under the smaller model. The <F-test> compares a gain in fit with its extra degrees of freedom; simply obtaining a smaller <residual sum of squares> is automatic and is not itself evidence that the larger model generalizes better.