Tutorials › High-Dimensional Genomic Data Analysis › Ridge Shrinkage Along Design-Matrix Directions

Penalized Regression for p Much Larger Than n · Tutorial 516 of 795

Ridge Shrinkage Along Design-Matrix Directions

See how ridge selectively shrinks fitted signal according to design-matrix singular values, and calculate the model’s effective degrees of freedom.

Advanced 12 min read

What You'll Learn

  • Express ridge coefficients and fitted values using the singular vectors of the design matrix.
  • Distinguish shrinkage of coefficient coordinates from shrinkage of fitted signal coordinates.
  • Calculate directional shrinkage factors from singular values and the penalty parameter.
  • Derive effective degrees of freedom as the trace of the ridge smoother matrix.
  • Track how increasing the penalty changes fitted signal and effective degrees of freedom.
  • Recognize the role of rank deficiency, an unpenalized intercept, and the chosen penalty convention.

Why shrinkage depends on direction

Ridge regression does not shrink every feature coefficient by the same amount when viewed in the original predictor coordinates. Its action is simpler in directions formed from the design matrix’s singular vectors: each direction in the fitted signal is multiplied by a factor determined by its singular value and the penalty. Directions strongly represented in the design matrix are shrunk less; weak directions are shrunk more.

This perspective matters when \(p\), the number of predictors, is large relative to \(n\), the number of observations. The design matrix may have directions with very different levels of information, or even directions in which its columns provide no identifiable signal at all. Singular-vector coordinates reveal which directions ridge retains, how the penalty controls that retention, and why the effective degrees of freedom need not equal the number of predictors.

Model and directional representation

Assume the response vector \(y\) and the columns of the design matrix \(X\) have been centered, so an intercept can be handled separately and is not penalized. Use the ridge objective

$$ \hat{\beta}_{\lambda} = \arg\min_{\beta} \left\{ \|y-X\beta\|_2^2+\lambda\|\beta\|_2^2 \right\}, \qquad \lambda>0. $$

This convention has no factor of one-half in either term. Consequently, the penalty \(\lambda\) is compared with squared singular values of \(X\). Changing the scaling of the objective changes the numerical value assigned to the penalty parameter.

Definition: Write a compact singular value decomposition of \(X\) as \(X=UDV^\mathsf{T}\), where \(r=\operatorname{rank}(X)\), the columns \(u_1,\ldots,u_r\) of \(U\) are orthonormal, the columns \(v_1,\ldots,v_r\) of \(V\) are orthonormal, and \(D=\operatorname{diag}(d_1,\ldots,d_r)\) with \(d_j>0\). The \(u_j\) are directions in observation space, the \(v_j\) are directions in coefficient space, and \(d_j\) measures how strongly \(X\) maps \(v_j\) into \(u_j\).

Let \(z_j=u_j^\mathsf{T}y\) be the observed response component along \(u_j\). The response may also have a component orthogonal to every column of \(U\), but that component cannot be fitted by \(X\beta\). If \(b_j=v_j^\mathsf{T}\hat{\beta}_{\lambda}\), then the fitted signal’s component along \(u_j\) is \(d_j b_j\).

Deriving the amount of shrinkage

In these coordinates, the part of the squared error that depends on \(b_j\) is \((z_j-d_jb_j)^2\), and the penalty contribution is \(\lambda b_j^2\). The objective separates across singular directions. Differentiating the contribution for direction \(j\) gives

$$ \frac{\partial}{\partial b_j} \left\{(z_j-d_jb_j)^2+\lambda b_j^2\right\} = -2d_j(z_j-d_jb_j)+2\lambda b_j. $$

Setting this derivative to zero yields \((d_j^2+\lambda)b_j=d_jz_j\), and hence \(b_j=d_jz_j/(d_j^2+\lambda)\). Multiplying by \(d_j\) converts the coefficient coordinate into the fitted signal coordinate:

$$ v_j^\mathsf{T}\hat{\beta}_{\lambda} = \frac{d_j}{d_j^2+\lambda}z_j, \qquad u_j^\mathsf{T}\hat{y}_{\lambda} = d_jv_j^\mathsf{T}\hat{\beta}_{\lambda} = \frac{d_j^2}{d_j^2+\lambda}z_j. $$
Key result: The ridge shrinkage factor for the fitted signal in direction \(u_j\) is \(s_j(\lambda)=d_j^2/(d_j^2+\lambda)\). For \(\lambda>0\), this factor is between zero and one. Relative to the unpenalized fitted component \(z_j\), the direction is retained in proportion to \(s_j(\lambda)\).

The coefficient coordinate has a different formula from the fitted signal coordinate. When \(d_j\) is small, its coefficient multiplier \(d_j/(d_j^2+\lambda)\) can be small, even though that does not directly describe the fraction of the response component retained. For comparing fitted signal across directions, use \(s_j(\lambda)\).

Worked Example: Shrinkage in Three Directions

Suppose a hypothetical centered design matrix has singular values \(d_1=4\), \(d_2=2\), and \(d_3=1\). Suppose the response projections onto the corresponding left singular vectors are \(z_1=6\), \(z_2=-3\), and \(z_3=2\). With \(\lambda=4\), calculate the fitted component in each direction.

The squared singular values are \(16\), \(4\), and \(1\). The three shrinkage factors are

$$ s_1(4)=\frac{16}{16+4}=0.8,\qquad s_2(4)=\frac{4}{4+4}=0.5,\qquad s_3(4)=\frac{1}{1+4}=0.2. $$

Multiplying each response projection by its factor gives fitted components \(0.8(6)=4.8\), \(0.5(-3)=-1.5\), and \(0.2(2)=0.4\). Thus \(\hat{y}_{\lambda}\) has the component \(4.8u_1-1.5u_2+0.4u_3\) in the column space of \(X\). The strongest design direction, \(u_1\), retains the greatest fraction of its observed response projection; the weakest, \(u_3\), retains the least.

For comparison, the unpenalized fitted components in these directions would be \(6\), \(-3\), and \(2\). The ridge fit has reduced each component toward zero, not reversed its sign.

Effective degrees of freedom

For a fixed \(X\) and \(\lambda\), ridge fitted values are a linear transformation of \(y\): \(\hat{y}_{\lambda}=S_{\lambda}y\), where \(S_{\lambda}\) is called the smoother matrix. The effective degrees of freedom for this linear smoother are defined as \(\operatorname{tr}(S_{\lambda})\), the trace of that matrix.

Because \(X=UDV^\mathsf{T}\), the ridge fitted values can be written as \(U\operatorname{diag}(s_1(\lambda),\ldots,s_r(\lambda))U^\mathsf{T}y\). Therefore the smoother matrix is \(S_{\lambda}=U\operatorname{diag}(s_1(\lambda),\ldots,s_r(\lambda))U^\mathsf{T}\). Taking its trace and using \(U^\mathsf{T}U=I\) gives

$$ df_{\mathrm{eff}}(\lambda) = \operatorname{tr}(S_{\lambda}) = \sum_{j=1}^{r}\frac{d_j^2}{d_j^2+\lambda}. $$

This is a derivation of the effective degrees of freedom for the stated ridge objective and fixed design. Each direction contributes between zero and one, rather than counting as either a fully included or excluded parameter. If an unpenalized intercept is fitted in addition to centered predictors, its contribution is one; the displayed sum describes the centered predictor part.

Worked Example: Comparing Penalties and Effective Degrees of Freedom

For a hypothetical design with singular values \(5\), \(2\), and \(1\), calculate the effective degrees of freedom for \(\lambda=1\) and \(\lambda=9\), excluding any separate intercept.

At \(\lambda=1\), the squared singular values are \(25\), \(4\), and \(1\), so

$$ df_{\mathrm{eff}}(1) = \frac{25}{26}+\frac{4}{5}+\frac{1}{2} \approx 0.9615+0.8000+0.5000 = 2.2615. $$

At \(\lambda=9\),

$$ df_{\mathrm{eff}}(9) = \frac{25}{34}+\frac{4}{13}+\frac{1}{10} \approx 0.7353+0.3077+0.1000 = 1.1430. $$

The larger penalty reduces the effective degrees of freedom by about \(2.2615-1.1430=1.1185\). The reduction is not uniform across directions: the direction with \(d=1\) drops from a contribution of \(0.5\) to \(0.1\), while the direction with \(d=5\) still contributes about \(0.7353\). These numbers describe the fitted model’s effective complexity for this design, not a count of selected genes.

What changes as the penalty increases?

For each nonzero singular direction, the shrinkage factor decreases as \(\lambda\) increases. Differentiating with respect to \(\lambda\) gives

$$ \frac{\partial s_j(\lambda)}{\partial\lambda} = -\frac{d_j^2}{(d_j^2+\lambda)^2}<0. $$

The same monotonicity holds for effective degrees of freedom, since it is the sum of these factors. As \(\lambda\) approaches zero from above, each nonzero direction approaches a factor of one and \(df_{\mathrm{eff}}\) approaches \(r\). As \(\lambda\) grows without bound, the factors and the predictor contribution to \(df_{\mathrm{eff}}\) approach zero. Ridge therefore moves continuously between a fit that uses the full column space and a fit with predictor signal shrunk nearly to zero.

A direction’s factor depends on the ratio of \(\lambda\) to \(d_j^2\). If \(d_j^2\) is much larger than \(\lambda\), then \(s_j(\lambda)\) is close to one. If \(d_j^2\) is much smaller than \(\lambda\), the factor is close to zero. The penalty has its strongest relative effect on directions with small singular values, which often correspond to combinations of predictors that are difficult to distinguish from one another.

Worked Example: A Rank-Deficient High-Dimensional Design

Consider a hypothetical centered design matrix with \(n=3\) observations and \(p=5\) predictors, of rank \(r=2\). Its two positive singular values are \(3\) and \(1\). Suppose the response projections are \(z_1=2\) and \(z_2=-4\) along the two left singular vectors, and its remaining component is orthogonal to the column space of \(X\). Set \(\lambda=2\).

The fitted signal factors are \(9/(9+2)=9/11\) and \(1/(1+2)=1/3\). Thus the fitted components in the two estimable directions are

$$ \frac{9}{11}(2)=\frac{18}{11}\approx 1.636, \qquad \frac{1}{3}(-4)=-\frac{4}{3}\approx -1.333. $$

The response component orthogonal to the column space remains in the residual: no choice of \(\beta\) can fit it. The effective degrees of freedom for the predictor fit are

$$ df_{\mathrm{eff}}(2) = \frac{9}{11}+\frac{1}{3} = \frac{38}{33} \approx 1.152. $$

Although there are five predictors, only two singular directions have nonzero singular values, and the penalty reduces the total effective degrees of freedom below two. Coefficient components in the null space of \(X\) do not improve fitted values; for \(\lambda>0\), the ridge penalty sets those unidentifiable components to zero.

Assumptions, diagnostics, and comparisons

The directional algebra requires a fixed design matrix, the stated squared-error ridge objective, and a consistent penalty convention. It does not require normally distributed errors: the shrinkage factors follow directly from the optimization problem. A probabilistic interpretation of sampling variability or prediction uncertainty would require additional assumptions about how \(y\) varies around its mean. Predictor scaling also matters: rescaling columns changes the singular values and thus changes which directions are penalized most. The interpretation here assumes that scaling and centering have been chosen deliberately.

If the model includes an intercept, it is usually left unpenalized; centering makes the singular-direction expressions for the predictors easy to state separately. If the intercept is instead penalized, it participates in the penalty and the preceding formulas must be applied to the full design as specified. Likewise, a software package using \(\|y-X\beta\|_2^2/(2n)+\lambda\|\beta\|_2^2/2\) uses a different numerical scaling of \(\lambda\) from the objective used here.

The singular values and the resulting direction-wise factors provide a useful calculation check. For \(\lambda>0\), every factor must lie strictly between zero and one, and a smaller singular value must have a smaller factor when \(\lambda\) is fixed. The effective degrees of freedom must lie between zero and \(r\), and must decrease as \(\lambda\) increases. A factor above one, a negative effective degree of freedom, or a larger factor in a weaker direction signals an algebra or convention mismatch.

Unpenalized least squares retains every nonzero singular direction fully, so its fitted-value degrees of freedom are \(r\). It can be unstable in weak directions, and when \(p>n\) its coefficients need not be unique. Ridge instead shrinks all nonzero directions continuously. A different approach is truncated singular value decomposition, which keeps selected directions at full strength and discards the rest. Ridge uses gradual rather than all-or-nothing retention; neither approach guarantees that the retained directions correspond to individual genes or causal effects.

A common mistake is to say that ridge multiplies every original gene coefficient by the same shrinkage factor. That is generally false: correlated predictors mix across the singular-vector directions, and the factor \(d_j^2/(d_j^2+\lambda)\) applies to the fitted signal along \(u_j\), not to each original coefficient. Another mistake is to interpret effective degrees of freedom as the number of nonzero coefficients. Ridge coefficients are generally not exactly zero; the trace measures the aggregate sensitivity of fitted values to the response.

Key takeaway: Ridge retains a fraction \(d_j^2/(d_j^2+\lambda)\) of the response projection in each singular direction. Summing these fractions gives the effective degrees of freedom for the centered predictor fit, making the role of both design strength and penalty size explicit.

Check Your Understanding

Work through each question, then compare with the solutions below.

  1. A direction has singular value \(d=3\) and penalty \(\lambda=3\). What fraction of its response projection is fitted?
  2. A design has singular values \(2\) and \(1\). Find the effective degrees of freedom at \(\lambda=1\), excluding an intercept.
  3. What happens to a response component orthogonal to the column space of \(X\) under ridge fitting?
  4. Why is the effective degrees of freedom not generally the number of nonzero ridge coefficients?

Solutions. (1) The factor is \(d^2/(d^2+\lambda)=9/(9+3)=0.75\), so 75% of that response projection is fitted. (2) The sum is \(4/(4+1)+1/(1+1)=0.8+0.5=1.3\). (3) It remains in the residual because every fitted vector \(X\beta\) lies in the column space of \(X\). (4) Ridge generally leaves coefficients nonzero, whereas effective degrees of freedom are defined as the trace of the smoother matrix, \(\sum_j d_j^2/(d_j^2+\lambda)\); this is a sensitivity-based measure of fit complexity, not a coefficient count.

Clinical Biostats