Ridge Tuning & GCV
A ridge fit is easy to calculate for a fixed penalty. The practical question is how much shrinkage improves prediction. Cross-validation and generalized cross-validation compare candidate penalties while accounting for the model’s flexibility.
Effective Degrees of Freedom¶
For a fixed response-independent design and penalty,
Under common error variance, the covariance definition of model complexity gives
Each observed singular direction contributes between zero and one effective parameter. With all coefficients penalized, df decreases from as to zero as .
With an unpenalized intercept and centered predictor matrix , the full smoother is
so
The extra one counts the fitted intercept. Here df tends to one as slopes are completely shrunk.
Exact LOO for a Fixed Ridge Procedure¶
For sum-scale ridge with the same numerical in every deleted fit,
The identity also holds with a fixed penalty matrix that leaves the intercept unpenalized, provided the relevant deleted systems are invertible.
Why the OLS Shortcut Extends to Ridge
Set , where for ordinary ridge or with an unpenalized intercept. Deleting observation changes to while leaving fixed.
The same Sherman-Morrison calculation as in LOO & Generalized Cross-Validation yields
Thus the deleted-fit residual is .
If software uses mean loss and keeps fixed, the sum-scale penalty changes from to on deletion. The displayed full-fit shortcut assumes a fixed sum-scale penalty. Re-estimating predictor scales, selecting features, or retuning inside each deletion also changes the fitting procedure; use explicit folds to evaluate such a pipeline.
Generalized Cross-Validation¶
Replace individual leverages by their average:
Choose a candidate penalty with the smallest score and refit with that penalty. GCV approximates LOO by using a common leverage correction; it is not an additional exact deleted-data formula.
| As increases | Typical consequence |
|---|---|
| Coefficient norm decreases | Less sensitivity to response noise. |
| Training RSS increases or stays constant | The fit moves away from its least-squares optimum. |
| Effective df decreases | The GCV complexity correction becomes smaller. |
| Bias can increase | Excessive shrinkage can lose predictive signal. |
The GCV score itself need not be monotone. Search a sufficiently broad grid, often spaced logarithmically. If the minimum lies at an edge, examine whether extending the range is appropriate. Include the OLS limit only when the denominator is nonzero and the numerical calculation is stable.
The minimum GCV score has been used for selection. It should not be treated as an unbiased final assessment of the chosen model. Use a held-out test set or outer CV when a separate assessment is needed.
Efficient Evaluation Across Penalties¶
For the all-penalized convention, precompute a compact SVD and . Write . Then
Orthogonality makes the two residual components add without a cross term. After the SVD, both RSS and df require only sums over directions for each candidate penalty. For an unpenalized intercept, apply the same decomposition to and , then add one to df.
Residual Variance Is a Different Quantity¶
For a fixed smoother and true mean vector ,
For correctly specified OLS, the bias term is zero and , giving . For ridge, the bias term generally remains and . Therefore is not generally an unbiased variance estimator. GCV does not require a separate estimate of .
Worked Spectral Comparison¶
Consider , two orthogonal design directions with , projected response coordinates , and . All coefficients are penalized in this example.
| Shrinkage weights | df | RSS | GCV | |
|---|---|---|---|---|
| 0 | 2.0 | 2.00 | 1.1111 | |
| 1 | 1.4 | 2.34 | 0.9028 | |
| 9 | 0.6 | 5.06 | 1.3068 |
Among these three candidates, has the lowest score. It allows a modest RSS increase while substantially reducing effective complexity. This discrete comparison does not claim that 1 minimizes GCV over every positive penalty.