The proof of shrinking coefficients using ridge regression through "spectral decomposition" - Cross Validated most recent 30 from stats.stackexchange.com 2019-07-21T15:58:12Z https://stats.stackexchange.com/feeds/question/220243 http://www.creativecommons.org/licenses/by-sa/3.0/rdf https://stats.stackexchange.com/q/220243 20 The proof of shrinking coefficients using ridge regression through "spectral decomposition" jeza https://stats.stackexchange.com/users/120788 2016-06-23T04:08:15Z 2017-08-11T16:45:46Z <p>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."</p> https://stats.stackexchange.com/questions/220243/-/220324#220324 29 Answer by whuber for The proof of shrinking coefficients using ridge regression through "spectral decomposition" whuber https://stats.stackexchange.com/users/919 2016-06-23T14:50:40Z 2017-08-11T16:45:46Z <p>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 <a href="https://en.wikipedia.org/wiki/Singular_value_decomposition" rel="noreferrer">Singular Value Decomposition</a> (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.)</p> <p>The original source of this answer can be found in <a href="http://www.quantdec.com/misc/MAT8406/Meeting12/index.html" rel="noreferrer">my regression course notes</a>. This version corrects some minor errors.</p> <hr> <h2>What the SVD is</h2> <p>Any $n\times p$ matrix $X$, with $p \le n$, can be written $$X = UDV^\prime$$ where </p> <ol> <li><p>$U$ is an $n\times p$ matrix.</p> <ul> <li>The columns of $U$ have length $1$.</li> <li>The columns of $U$ are mutually orthogonal.</li> <li>They are called the <em>principal components</em> of $X$.</li> </ul></li> <li><p>$V$ is a $p \times p$ matrix.</p> <ul> <li>The columns of $V$ have length $1$.</li> <li>The columns of $V$ are mutually orthogonal.</li> <li>This makes $V$ a <em>rotation</em> of $\mathbb{R}^p$.</li> </ul></li> <li><p>$D$ is a <em>diagonal</em> $p \times p$ matrix.</p> <ul> <li>The diagonal elements $d_{11}, d_{22}, \ldots, d_{pp}$ are not negative. These are the <em>singular values</em> of $X$.</li> <li>If we wish, we may order them from largest to smallest.</li> </ul></li> </ol> <p>Criteria (1) and (2) assert that both $U$ and $V$ are <em>orthonormal</em> matrices. They can be neatly summarized by the conditions</p> <p>$$U^\prime U = 1_p,\ V^\prime V = 1_p.$$</p> <p>As a consequence (that $V$ represents a rotation), $VV^\prime = 1_p$ also. This will be used in the Ridge Regression derivation below.</p> <h2>What it does for us</h2> <p><strong><em>It can simplify formulas.</em></strong> This works both algebraically and conceptually. Here are some examples.</p> <h3>The Normal Equations</h3> <p>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:</p> <p>$$(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.$$</p> <p>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.</p> <p>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}$.</p> <h3>Covariance of the coefficient estimates</h3> <p>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$ <em>orthogonal</em> variables, each with variances $d^2_{ii}$, that have been rotated in $\mathbb{R}^k$.</p> <h3>The Hat matrix</h3> <p>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!</p> <h3>Eigenanalysis (spectral decomposition)</h3> <p>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</p> <ul> <li>The eigenvalues of $X^\prime X$ and $XX^\prime$ are the squares of the singular values.</li> <li>The columns of $V$ are the eigenvectors of $X^\prime X$.</li> <li>The columns of $U$ are some of the eigenvectors of $X X^\prime$. (Other eigenvectors exist but correspond to zero eigenvalues.)</li> </ul> <p><strong>SVD can diagnose and solve collinearity problems.</strong></p> <h3>Approximating the regressors</h3> <p>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$, <strong>effectively reducing the number of variables.</strong> Provided those eliminated columns have little correlation with $y$, <strong>this can work effectively as a variable-reduction technique.</strong></p> <h2>Ridge Regression</h2> <p>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 &amp;= (X^\prime X + \lambda)^{-1}X^\prime y \\ &amp;= (VD^2V^\prime + \lambda\,1_p)^{-1}VDU^\prime y \\ &amp;= (VD^2V^\prime + \lambda V V^\prime)^{-1}VDU^\prime y \\ &amp;= (V(D^2 + \lambda)V^\prime)^{-1} VDU^\prime y \\ &amp;= V(D^2+\lambda)^{-1}V^\prime V DU^\prime y \\ &amp;= V(D^2 + \lambda)^{-1} D U^\prime y.\end{aligned}</p> <p><strong>The difference between this and $\hat\beta$ is the replacement of $D^{-1} = D^{-2}D$ by $(D^2+\lambda)^{-1}D$.</strong> 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, <em>the parameter estimates "shrink towards zero."</em> </p> <hr> <p>This result has to be understood in the somewhat subtle sense alluded to previously: the <em>rotated</em> 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 <em>rotated</em> 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.</p> <p>To avoid distractions, the case of one of more zero singular values was excluded in this discussion. In such circumstances, <em>if we conventionally take "$d_{ii}^{-1}$" to be zero,</em> then everything still works. This is what is going on when <a href="https://en.wikipedia.org/wiki/Moore%E2%80%93Penrose_pseudoinverse#Linear_least-squares" rel="noreferrer">generalized inverses</a> are used to solve the Normal equations.</p>