I have understood how ridge regression shrinks coefficients towards zero geometrically. Moreover I know how to prove that in the special "Orthonormal Case," but I am confused how that works in the general case via "Spectral decomposition."

  • 4
    $\begingroup$ You have stated you are confused, but what is your question? $\endgroup$ – whuber Jun 23 '16 at 14:18

The question appears to ask for a demonstration that Ridge Regression shrinks coefficient estimates towards zero, using a spectral decomposition. The spectral decomposition can be understood as an easy consequence of the Singular Value Decomposition (SVD). Therefore, this post starts with SVD. It explains it in simple terms and then illustrates it with important applications. Then it provides the requested (algebraic) demonstration. (The algebra, of course, is identical to the geometric demonstration; it merely is couched in a different language.)

The original source of this answer can be found in my regression course notes. This version corrects some minor errors.

What the SVD is

Any $n\times p$ matrix $X$, with $p \le n$, can be written $$X = UDV^\prime$$ where

  1. $U$ is an $n\times p$ matrix.

    • The columns of $U$ have length $1$.
    • The columns of $U$ are mutually orthogonal.
    • They are called the principal components of $X$.
  2. $V$ is a $p \times p$ matrix.

    • The columns of $V$ have length $1$.
    • The columns of $V$ are mutually orthogonal.
    • This makes $V$ a rotation of $\mathbb{R}^p$.
  3. $D$ is a diagonal $p \times p$ matrix.

    • The diagonal elements $d_{11}, d_{22}, \ldots, d_{pp}$ are not negative. These are the singular values of $X$.
    • If we wish, we may order them from largest to smallest.

Criteria (1) and (2) assert that both $U$ and $V$ are orthonormal matrices. They can be neatly summarized by the conditions

$$U^\prime U = 1_p,\ V^\prime V = 1_p.$$

As a consequence (that $V$ represents a rotation), $VV^\prime = 1_p$ also. This will be used in the Ridge Regression derivation below.

What it does for us

It can simplify formulas. This works both algebraically and conceptually. Here are some examples.

The Normal Equations

Consider the regression $y = X\beta + \varepsilon$ where, as usual, the $\varepsilon$ are independent and identically distributed according to a law that has zero expectation and finite variance $\sigma^2$. The least squares solution via the Normal Equations is $$\hat\beta = (X^\prime X)^{-1} X^\prime y.$$ Applying the SVD and simplifying the resulting algebraic mess (which is easy) provides a nice insight:

$$(X^\prime X)^{-1} X^\prime = ((UDV^\prime)^\prime (UDV^\prime))^{-1} (UDV^\prime)^\prime \\= (VDU^\prime U D V^\prime)^{-1} (VDU^\prime) = VD^{-2}V^\prime VDU^\prime = VD^{-1}U^\prime.$$

The only difference between this and $X^\prime = VDU^\prime$ is that the reciprocals of the elements of $D$ are used! In other words, the "equation" $y=X\beta$ is solved by "inverting" $X$: this pseudo-inversion undoes the rotations $U$ and $V^\prime$ (merely by transposing them) and undoes the multiplication (represented by $D$) separately in each principal direction.

For future reference, notice that "rotated" estimates $V^\prime \hat\beta $ are linear combinations of "rotated" responses $U^\prime y$. The coefficients are inverses of the (positive) diagonal elements of $D$, equal to $d_{ii}^{-1}$.

Covariance of the coefficient estimates

Recall that the covariance of the estimates is $$\text{Cov}(\hat\beta) = \sigma^2(X^\prime X)^{-1}.$$ Using the SVD, this becomes $$\sigma^2(V D^2 V^\prime)^{-1} = \sigma^2 V D^{-2} V^\prime.$$ In other words, the covariance acts like that of $k$ orthogonal variables, each with variances $d^2_{ii}$, that have been rotated in $\mathbb{R}^k$.

The Hat matrix

The hat matrix is $$H = X(X^\prime X)^{-1} X^\prime.$$ By means of the preceding result we may rewrite it as $$H = (UDV^\prime)(VD^{-1}U^\prime) = UU^\prime.$$ Simple!

Eigenanalysis (spectral decomposition)

Since $$X^\prime X = VDU^\prime U D V^\prime = VD^2V^\prime$$ and $$XX^\prime = UDV^\prime VDU^\prime = UD^2U^\prime,$$ it is immediate that

  • The eigenvalues of $X^\prime X$ and $XX^\prime$ are the squares of the singular values.
  • The columns of $V$ are the eigenvectors of $X^\prime X$.
  • The columns of $U$ are some of the eigenvectors of $X X^\prime$. (Other eigenvectors exist but correspond to zero eigenvalues.)

SVD can diagnose and solve collinearity problems.

Approximating the regressors

When you replace the smallest singular values with zeros, you will change the product $UDV^\prime$ only slightly. Now, however, the zeros eliminate the corresponding columns of $U$, effectively reducing the number of variables. Provided those eliminated columns have little correlation with $y$, this can work effectively as a variable-reduction technique.

Ridge Regression

Let the columns of $X$ be standardized, as well as $y$ itself. (This means we no longer need a constant column in $X$.) For $\lambda \gt 0$ the ridge estimator is $$\begin{aligned}\hat\beta_R &= (X^\prime X + \lambda)^{-1}X^\prime y \\ &= (VD^2V^\prime + \lambda\,1_p)^{-1}VDU^\prime y \\ &= (VD^2V^\prime + \lambda V V^\prime)^{-1}VDU^\prime y \\ &= (V(D^2 + \lambda)V^\prime)^{-1} VDU^\prime y \\ &= V(D^2+\lambda)^{-1}V^\prime V DU^\prime y \\ &= V(D^2 + \lambda)^{-1} D U^\prime y.\end{aligned}$$

The difference between this and $\hat\beta$ is the replacement of $D^{-1} = D^{-2}D$ by $(D^2+\lambda)^{-1}D$. In effect, this multiplies the original by the fraction $D^2/(D^2+\lambda)$. Because (when $\lambda \gt 0$) the denominator is obviously greater than the numerator, the parameter estimates "shrink towards zero."

This result has to be understood in the somewhat subtle sense alluded to previously: the rotated estimates $V^\prime\hat\beta_R$ are still linear combinations of the vectors $U^\prime y$, but each coefficient--which used to be $d_{ii}^{-1}$--has been multiplied by a factor of $d_{ii}^2/(d_{ii}^2 + \lambda)$. As such, the rotated coefficients must shrink, but it is possible, when $\lambda$ is sufficiently small, for some of the $\hat\beta_R$ themselves actually to increase in size.

To avoid distractions, the case of one of more zero singular values was excluded in this discussion. In such circumstances, if we conventionally take "$d_{ii}^{-1}$" to be zero, then everything still works. This is what is going on when generalized inverses are used to solve the Normal equations.

  • 1
    $\begingroup$ @Glen_b That's a good point: I needed to be explicit about what fraction I was considering! I'll fix that. $\endgroup$ – whuber Jun 23 '16 at 18:49
  • 1
    $\begingroup$ (1) Part of the equation $UU^\prime=1_p$ asserts that the dot product of each column of $U$ with itself is $1$, whence each length is (by definition) $\sqrt{1}=1$. (2) $VV^\prime=1_p$ follows from the observation that $V$ is a rotation matrix, because this implies $V^{-1}$ is also a rotation matrix. Therefore $(V^{-1})^\prime(V^{-1})=1_p$. Plugging in $V^{-1}=V^\prime$ gives $VV^\prime=(V^\prime)^\prime V^\prime=1_p$. $\endgroup$ – whuber Jun 24 '16 at 3:15
  • 1
    $\begingroup$ @Vimal Thank you for the good suggestion. I have now included an explanation in the "Normal Equations" section where the regression model is introduced. $\endgroup$ – whuber Jul 12 '16 at 18:08
  • 1
    $\begingroup$ When $X$ is symmetric, then by definition $$VDU^\prime=X^\prime=X=UDV^\prime.$$ Comparing the left and right sides immediately shows the diagonalization of a real symmetric matrix is a special case of the SVD and also suggests that in the SVD of a symmetric matrix, $U=V$. That in fact is the case provided $X$ is nondegenerate--but proving it is not entirely elementary, so I won't go into details. $\endgroup$ – whuber Jul 18 '16 at 14:00
  • 1
    $\begingroup$ @ whuber, oh , is it like this ? In the fitted value $\hat{y}$ we will use the coefficients estimates and as long as they are shrunk towards zero the same will happen for the fitted value. $\endgroup$ – jeza Jul 22 '16 at 22:08

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.