Use an unpenalized intercept in ridge regression. For centered predictor columns, the ridge regression optimization is
Differentiating with respect to gives . Put . Differentiation with respect to gives the ridge normal equation
Consequently the closed-form ridge regression estimator is
Because , the numerator may also be written . For the inverse exists even with multicollinearity or deficient column rank; at a unique ordinary least squares coefficient vector requires full rank. The quadratic penalty stabilizes nearly singular directions but generally does not set individual coefficients exactly to zero.
For uncentered original predictors, use , apply the displayed estimator to , and recover . Any internal scaling used by lm.ridge must be undone to report coefficients on the original predictor scale. Multiplying the objective by a constant changes the numerical penalty convention unless is rescaled as well.