Closed-form ridge regression estimator Created 2026-09-29 Updated 2026-10-05
For , the ridge regression objective has gradient . The matrix is positive definite, so the unique minimizer is .
Covariance and bias of a ridge regression estimator Created 2026-10-05 Updated 2026-10-06
For a fixed centered design matrix , independent errors of variance , and objective , put and . The ridge regression estimator hasThus its standard error alone does not justify centering a confidence interval for at the biased estimator. A penalty chosen from the responses also changes its sampling distribution.
Fitted values Created 2026-09-24 Updated 2026-10-14
Fitted values are the predictions at the predictor values used to fit a regression model. In linear regression with an explicit regression intercept,Here is the slope design matrix, and is the regression residual vector. The fitted values estimate the regression function at the observed predictors; they need not equal the observed responses, which may also contain random errors. Prediction at a new predictor vector uses with the same centering and scaling used in fitting. A prediction interval addresses uncertainty in a new response rather than just displaying this point prediction.
For the five constructed observations in linear regression, ordinary least squares gives fitted values . The ridge regression fit at instead gives . Both fitted vectors have sample mean because the regression intercept is unpenalized; their regression residuals differ and their residual sums of squares are and , respectively.
For ordinary least squares, the fitted values are the orthogonal projection of onto the column space of the complete design matrix, including its regression intercept column. They remain unique even in rank-deficient ordinary least squares, although the regression coefficients can be nonunique. The regression residuals are then orthogonal to every column.[ref]
Regression 1: Different perspectives. slides 6–10: fitted values, hat matrix, projection and orthogonal residuals
With centered slopes, ridge regression instead satisfies , so the regression residuals need not be orthogonal to the slope columns. Their sum is still zero because the regression intercept remains free.For fixed predictors and scales and a fixed positive penalty, ridge regression gives a linear smoother,For with at least one nonzero slope direction, this matrix is not an orthogonal projection matrix: applying it twice shrinks that direction again. Its effective degrees of freedom are , where are the positive singular values of ; the extra counts the free regression intercept. If the penalty is selected using , the resulting fitting rule need not be a linear smoother, since its chosen also depends on .
For likelihood and independent prior , the posterior distribution is Gaussian with covariance as displayed and mean . Its mean and mode therefore coincide with the ridge regression coefficient estimate. A Gaussian prior alone does not imply this conclusion without the stated likelihood.
// Target: foundations-of-mathematics.bigb
Kernel ridge regression Created 2026-09-24 Updated 2026-10-14
Kernel ridge regression minimizes empirical squared error plus the squared norm in a Reproducing kernel Hilbert space. The representer theorem reduces it to ridge regression with the kernel matrix as its feature Gram matrix.
Lava estimator 2026-10-05
The Lava estimator minimizes . It combines a component selected by Lasso with a component shrunk by ridge regression. Profiling the latter yields a transformed Lasso problem; this is not the same coefficient penalty as elastic net regularization.
Past exam of the mathematics course of the University of Cambridge 2008 iii Paper 45 2 a Solution Created 2026-10-03 Updated 2026-10-14
For an design matrix, distinguish the coefficient vector from the fitted-response vector. The ridge regression objective and its solution areThe gradient is . For , is a positive-definite matrix, so this is the unique minimizer even if is rank deficient. The expression with an additional leading is instead the -vector of fitted values,This distinction corrects the dimensional mismatch in the printed coefficient-estimator notation.
The quadratic penalty discourages large coefficients, exchanging some bias for lower variance. If is a reduced singular value decomposition, with positive singular values , thenThe principal-component shrinkage by ridge regression therefore shrinks directions with small most strongly. These are precisely the poorly determined directions created by multicollinearity, where ordinary least-squares coefficients can have large variance or fail to be uniquely determined. A positive penalty stabilizes their inversion and sets coefficients in the null space to zero. It does not make the predictors independent or provide a universal risk improvement for every signal. Because the penalty depends on coefficient units, predictors are ordinarily standardized before choosing by cross-validation. An unpenalized intercept in ridge regression is handled separately by centering; the displayed objective either has no intercept or applies the penalty to every component included in .
Past exam of the mathematics course of the University of Cambridge 2008 iii Paper 45 2 c Solution Created 2026-10-03 Updated 2026-10-14
The ridge regression penalty is quadratic, whereas the Lasso uses an absolute-value penalty. To make the constants explicit, compareBoth trade goodness of fit against coefficient size, and both require sensible predictor scaling and tuning. Ridge continuously shrinks coefficient directions and generally retains all variables. The Lasso's nonsmooth penalty can set coefficients exactly to zero, so it performs variable selection as well as shrinkage. When , let . The distinction is especially transparent:The second formula is soft thresholding. For general designs, the Karush-Kuhn-Tucker conditions for the Lasso give for a nonzero coefficient and for a zero coefficient. The latter interval permits exact zeros; the ridge equation instead is .
Ridge is especially useful for stable prediction when many predictors carry small effects or are highly correlated. Its strictly convex penalty gives unique coefficients for even in a rank-deficient design. It shares an effect among identical predictor columns: for a fixed coefficient sum the minimum quadratic penalty splits that sum equally. The Lasso can give a simpler sparse model when many effects are absent, but selection among strongly correlated predictors can be unstable. With identical columns, any same-sign split of a selected coefficient sum has the same absolute-value penalty and the same fitted values, so the coefficient vector need not be unique. This is a possible design degeneracy, not a claim that every Lasso fit is nonunique.
The penalties also encode different prior shapes: the Gaussian prior yields ridge, while independent double-exponential priors yield a Lasso posterior mode under Gaussian noise. A Lasso mode is not generally its posterior mean. Practically, sparse interpretability favors the Lasso, while stable distributed effects can favor ridge; prediction performance should be checked with cross-validation, and neither method universally dominates the other.
Past exam of the mathematics course of the University of Cambridge 2010 iii Paper 32 3 Solution Created 2026-10-03 Updated 2026-10-14
In a linear regression model, a large number of predictors or nearly dependent columns of the design matrix can make some eigenvalues of small. The ordinary least squares estimate has covariance matrix , so these directions have large variance, even though the estimator is unbiased. Ridge regression reduces this variance by shrinking the estimate towards zero, at the cost of introducing bias. This bias-variance tradeoff can improve the mean squared error when the signal is not too large in the shrunken directions.
For the usual preprocessing with a regression intercept, separate the constant column from the predictors and leave the intercept unpenalized. Subtract the sample mean from the response and from each nonconstant predictor, then divide each centered predictor column by its positive scale, for example its Euclidean norm. Thus all predictor columns have squared norm one; using squared norm instead simply changes the convention for the penalty. Centering is performed on the slope columns, not on the constant column. A full-rank design containing an intercept retains full rank on its centered slope columns. A model without an intercept should retain its specified mean structure unless an intercept is deliberately introduced.
Let be the resulting scaled, centered slope design matrix, let be the centered response, and let denote the coefficients in these standardized coordinates. The ridge regression problem isHere is the number of slopes; it is one less than the original number of columns when a constant column was present. The gradient of this objective is . Its Hessian matrix is a positive-definite matrix, giving the unique closed-form ridge regression estimatorThe regression intercept in the original coordinates is recovered as , and the original slopes are , where is the scale used for column . This is the unpenalized intercept in ridge regression convention. For a fixed full-rank coefficient design written simply as , with response and coefficient , the same formula readsThe risk comparison below first uses the fixed coefficient coordinates in which this quadratic penalty is imposed, and then addresses reversal of the scaling.
Assume at least one penalized coefficient, zero-mean errors with covariance matrix , and . No normal distribution assumption is needed for this mean squared error calculation. Put and . The covariance and bias of a ridge regression estimator follow directly from its linear expression:For the centered slope model, the response errors have covariance matrix , where . Since , the same coefficient covariance matrix formula still holds with .
By the spectral theorem for real symmetric matrices, write , with orthogonal and every , and put . The bias-variance decomposition of mean squared error now givesThe expression at is the ordinary least squares mean squared error. Its right derivative isTherefore, for every fixed coefficient vector, all sufficiently small positive penalties strictly improve mean squared error.
An explicit sufficient choice follows by subtracting the ordinary least squares risk term by term:Since , every summand is negative wheneverWhen , every positive penalty works. This is a pointwise result: the permitted penalty may depend on the true coefficient vector. A fixed positive penalty cannot improve risk for all arbitrarily large signals, because its squared bias grows quadratically with the signal. The same distinction appears in uniform directional risk improvement by ridge regression and unbounded directional risk of fixed ridge shrinkage. In centered coordinates the unpenalized intercept contributes the same to both coefficient risks, so it does not affect the improvement. Reversing a fixed predictor scaling measures coefficient error with a fixed positive-definite matrix instead of the identity matrix. For this weighted loss the squared bias still has derivative zero at , while the variance term has derivativeThe inequality follows because . Thus sufficiently small penalties also improve the original-coordinate mean squared error, though the explicit sufficient bound above was for the unweighted coordinates. Recovering an uncentered intercept adds a fixed nonnegative quadratic form to the slope loss, and its sample-mean error is uncorrelated with the centered slope errors, so the same weighted argument applies. A model with only an unpenalized intercept gives identical estimators. If the noise variance were zero, the strict improvement assertion would fail; positive noise variance is essential.
Past exam of the mathematics course of the University of Cambridge 2013 iii Paper 31 3 Solution Created 2026-10-03 Updated 2026-10-07
With the same squared-error normalization as in Question 2, the ridge estimator solvesThe unpenalized intercept in ridge regression is because the columns of are centered. Differentiating the remaining quadratic objective gives . Since , the left matrix is positive definite even when is rank-deficient. Thus the closed-form ridge regression estimator isThe second equality again uses centering. If the penalty convention is with an unnormalized squared-error term , replace by throughout; the limiting assertion is unchanged.
For the full-column-rank case, take a singular value decomposition with positive singular values . The ordinary least squares estimator, which is the slope maximum-likelihood estimator in this normal linear model, and the ridge regression estimator are respectivelyConsequently principal-component shrinkage by ridge regression multiplies the least-squares coordinate in direction by . Ridge shrinks most strongly in directions with the smallest singular values. These are combinations of predictors that the data distinguish least well.
Near multicollinearity creates small singular values, and the factor in ordinary least squares greatly amplifies noise in those directions. Its coefficient variance there is , while the ridge variance iswhich is smaller. The price is bias: the expectation of the ridge coordinate is times the corresponding true coefficient. This bias-variance tradeoff can substantially reduce estimation and prediction error when the poorly identified directions do not contain an excessively large signal. It is not a guarantee of improvement for every coefficient vector. Adding to every eigenvalue also improves the condition number of the normal matrix and makes numerical inversion more stable.
To handle every rank and every relation between and , put and use its spectral theorem for real symmetric matrices. Choose an orthonormal eigenbasis with eigenvalues , and put . ThenIf , then , so and . Thus these terms are exactly zero for every positive ; there is no divergent component in the null space. Each remaining term converges to . By the definition of the Moore-Penrose pseudoinverse,and thereforeThis proves the vanishing-penalty ridge limit without an invertibility assumption. The limit is the minimum-norm least-squares solution: every other least-squares solution differs by a vector in , orthogonal to the displayed solution, and therefore has at least as large a Euclidean norm.
Past exam of the mathematics course of the University of Cambridge 2013 iii Paper 32 7 i Solution Created 2026-10-03 Updated 2026-10-07
Choose candidate variables from subject-matter knowledge, measurement quality and the target question before screening on outcomes. For an adjusted-effect analysis, retain prespecified confounders and essential design variables even when their individual values are large. For prediction, consider reliable predictors available at the intended prediction time; do not include future information. Handle missingness transparently, using a justified multiple imputation strategy where appropriate rather than changing the analyzed population unpredictably as variables enter.
Encode a categorical variable with indicators relative to a stated reference category, and assess it as a group. Check multicollinearity, sparse categories and plausible interactions. The relevant information is chiefly the number and distribution of events, not merely the number of enrolled subjects: hundreds of correlated or rarely varying predictors cannot be supported by a small event count.
Compare prespecified nested models by a likelihood-ratio test based on the partial log-likelihood and the change in parameter dimension. Penalized methods such as ridge regression or Lasso regression applied to the Cox likelihood can stabilize many-variable models; choose tuning by suitable validation and account for mandatory variables. The Akaike information criterion or a limited, documented model-selection procedure can help balance fit and complexity. Unrestricted stepwise searches and repeated univariable screening invite unstable choices, omit joint confounding effects, and make naive post-selection intervals misleading. Prefer a defensible, validated covariate set to a collection chosen only for small values.
Past exam of the mathematics course of the University of Cambridge 2015 iii Paper 32 2 Solution Created 2026-10-03 Updated 2026-10-06
Put , which is a positive-definite matrix by the full column-rank assumption. The ordinary least squares estimator isFor ridge regression use the criterion . Differentiating givesIf instead the squared-error term is normalized by , replace in this formula and the calculations below by . Only the scale of the tuning parameter changes.
As usual for this linear regression model, use zero-mean errors; more generally suffices. Since the columns are centred, , so the random centring term disappears from both estimators. ThusLet . The bias and covariance matrix of the ridge regression estimator areThe bias-variance decomposition of mean squared error therefore represents directional risk by the quadratic formsTheir difference has the useful factorizationTo check it, multiply on both sides by : the resulting matrix is .
The Cauchy-Schwarz inequality gives in the Loewner order. Therefore the middle matrix is positive-definite whenever . For example,works, independently of the eigenvalues of . Since is invertible, the risk difference is strictly positive for every nonzero , in particular simultaneously for every unit . This proves uniform directional risk improvement by ridge regression. For the normalized-loss convention, take the displayed choice divided by .
For the final assertion, fix any and choose a unit eigenvector of with eigenvalue . Put and . Directly,Choosingmakes the squared bias alone greater than , proving the required strict inequality. Thus unbounded directional risk of fixed ridge shrinkage is compatible with the existence of a beneficial signal-dependent small penalty: no fixed positive penalty uniformly improves risk over all possible signals.
The mean assumption matters if the printed covariance condition is read in isolation. With , , , and , the columns and response are still centred and , but the ordinary least squares risk is . Writing , the ridge regression risk is for every . Hence the standard zero-mean regression-error convention, or its stated orthogonality version, is necessary for the first risk comparison; covariance alone is insufficient.
Past exam of the mathematics course of the University of Cambridge 2015 iii Paper 33 4 a Solution Created 2026-10-03 Updated 2026-10-06
Use an unpenalized intercept in ridge regression. For centered predictor columns, the ridge regression optimization isDifferentiating with respect to gives . Put . Differentiation with respect to gives the ridge normal equationConsequently the closed-form ridge regression estimator isBecause , 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. Past exam of the mathematics course of the University of Cambridge 2015 iii Paper 33 4 b Solution Created 2026-10-03 Updated 2026-10-06
The generalized cross-validation curve reaches its minimum at among the supplied grid values. This balances improved conditioning against shrinkage bias using an estimate of prediction error, rather than choosing the penalty with the smallest training residual sum of squares. Nearby values have similar errors, so the plot does not establish a highly precise optimal penalty.
Reading the PDF table at gives the fitted regression intercept and slopes:These table entries are necessary because the TeX stores the table only inside a figure. The ridge regression slopes are shrunk relative to the zero-penalty fit; their small nonzero values do not represent variable exclusion.
There is a minor source inconsistency: the prose says the predictors are centered, but the table's intercept varies with . With exactly centered predictor columns and an unpenalized intercept it would remain . The numbers above faithfully report the printed table, while part (a) gives the centered formula and the general uncentered conversion. The table therefore reflects a different or incompletely described preprocessing convention.
Past exam of the mathematics course of the University of Cambridge 2015 iii Paper 33 4 c Solution Created 2026-10-03 Updated 2026-10-06
An intercept-unpenalized Lasso estimator solves the constrained optimizationFor centered predictors, eliminate the intercept as in ridge regression and minimize under the same constraint. Equivalently, with a suitable tuning parameter , use . The constraint radius and penalty parameter are different parametrizations; larger radius permits less shrinkage.
The Lasso plot parametrizes the Lasso regularization path by the fraction of the maximum norm of the standardized slopes. Unlike the ridge quadratic penalty, the corners of the constraint can place some slopes exactly at zero, providing variable selection. The maximum norm refers to the path's unpenalized endpoint; centering and scaling conventions must match those used to construct that path.