Tutorials › Exam PA - Predictive Analytics › Soft-Thresholding in Orthogonal Regression

Exam PA · Lasso Selection and Elastic Net · Tutorial 431 of 966

Soft-Thresholding in Orthogonal Regression

Learn to derive and apply the lasso soft-thresholding rule for orthogonal predictors, including its dependence on predictor norms and the penalty convention.

Advanced 10 min read

What You'll Learn

  • State the assumptions under which orthogonal lasso coordinates separate.
  • Derive the soft-thresholding formula from the penalized least-squares objective.
  • Relate each coefficient’s threshold to its predictor’s squared norm.
  • Identify when a coefficient is exactly zero, including at the threshold boundary.
  • Avoid sign and objective-scaling errors when calculating updates.

Why Orthogonality Makes the Lasso Update Explicit

The lasso minimizes a residual sum of squares while penalizing the absolute sizes of the coefficients. In a general regression design, changing one coefficient also changes how the fitted values relate to other predictors. When the predictors are orthogonal, that coupling disappears: the objective separates into a sum of one-coefficient problems. Each coefficient can then be updated by a simple rule called soft-thresholding.

The rule is useful both as a calculation and as an explanation of lasso selection. A least-squares coefficient whose magnitude is at or below a penalty-dependent threshold becomes exactly zero. A coefficient above the threshold keeps its sign but is reduced in magnitude. The threshold depends on the penalty and on the scale of the corresponding predictor.

Definition: Predictors \(x_1,\ldots,x_p\) are orthogonal if \(x_j^\mathsf{T}x_k=0\) whenever \(j\ne k\). In this tutorial, assume the predictors and response have been centered, each predictor has positive squared norm, and the intercept, if included, is not penalized. Define \(q_j=x_j^\mathsf{T}x_j/n>0\), the normalized squared norm of predictor \(j\).

Use the lasso objective

$$ \frac{1}{2n}\sum_{i=1}^n\left(y_i-\sum_{j=1}^p x_{ij}\beta_j\right)^2 +\lambda\sum_{j=1}^p|\beta_j|,\qquad \lambda\ge 0. $$

This normalization matters: because the residual term is divided by \(2n\), the threshold derived below is \(\lambda/q_j\). If software or a problem statement uses a differently scaled residual term or penalty, the numerical threshold may also differ. No probability distribution for the response is needed for this least-squares derivation.

Deriving the Soft-Thresholding Formula

Write \(\widehat{\beta}^{\,LS}_j\) for the ordinary least-squares coefficient for predictor \(j\) in the orthogonal design. Since the predictors are centered and mutually orthogonal, the least-squares coefficient is

$$ \widehat{\beta}^{\,LS}_j=\frac{x_j^\mathsf{T}y}{x_j^\mathsf{T}x_j} =\frac{x_j^\mathsf{T}y/n}{q_j}. $$

Let \(z_j=x_j^\mathsf{T}y/n\). Orthogonality means the normalized residual sum of squares can be written as a constant independent of the coefficients plus a sum of separate quadratic terms:

$$ \frac{1}{2n}\left\|y-\sum_{j=1}^p x_j\beta_j\right\|^2 =C+\sum_{j=1}^p\left(\frac{q_j}{2}\beta_j^2-z_j\beta_j\right), $$

where \(C\) does not depend on \(\beta_1,\ldots,\beta_p\). For each \(j\), \(z_j=q_j\widehat{\beta}^{\,LS}_j\). Completing the square gives

$$ \frac{q_j}{2}\beta_j^2-z_j\beta_j =\frac{q_j}{2}\left(\beta_j-\widehat{\beta}^{\,LS}_j\right)^2 -\frac{q_j}{2}\left(\widehat{\beta}^{\,LS}_j\right)^2. $$

The final term on the right is constant with respect to \(\beta_j\). Thus the coordinate-specific minimization is equivalent to minimizing

$$ \frac{q_j}{2}\left(\beta_j-\widehat{\beta}^{\,LS}_j\right)^2+\lambda|\beta_j|. $$

For a nonzero coefficient, differentiate on the appropriate side of zero. If \(\beta_j>0\), the derivative is \(q_j(\beta_j-\widehat{\beta}^{\,LS}_j)+\lambda\); setting it equal to zero gives \(\beta_j=\widehat{\beta}^{\,LS}_j-\lambda/q_j\). This candidate is valid only if it is positive. If \(\beta_j<0\), the derivative is \(q_j(\beta_j-\widehat{\beta}^{\,LS}_j)-\lambda\); setting it equal to zero gives \(\beta_j=\widehat{\beta}^{\,LS}_j+\lambda/q_j\), which is valid only if it is negative.

At zero, the absolute-value penalty is not differentiable, so use its subgradient: the possible slopes of \(|\beta_j|\) at zero are all values in \([-1,1]\). Zero minimizes the coordinate objective exactly when a value \(s\in[-1,1]\) makes \(q_j(0-\widehat{\beta}^{\,LS}_j)+\lambda s=0\). Such a value exists if and only if \(q_j|\widehat{\beta}^{\,LS}_j|\le\lambda\). This explains why the boundary case is also zero, rather than a nonzero coefficient of either sign.

Theorem: Under the stated orthogonality and objective-scaling assumptions, the lasso coefficient is $$ \widehat{\beta}^{\,lasso}_j =\operatorname{sign}\!\left(\widehat{\beta}^{\,LS}_j\right) \max\left(\left|\widehat{\beta}^{\,LS}_j\right|-\frac{\lambda}{q_j},\,0\right). $$ Equivalently, it is zero when \(\left|\widehat{\beta}^{\,LS}_j\right|\le\lambda/q_j\); otherwise, it has the same sign as the least-squares coefficient and magnitude \(\left|\widehat{\beta}^{\,LS}_j\right|-\lambda/q_j\).

This operation is called soft-thresholding: values within the threshold are set to zero, while values outside it are pulled toward zero by the threshold amount. By contrast, hard-thresholding would keep a value unchanged once it passed the threshold. That is not the lasso update derived here.

Worked Applications

Worked Example: A Negative Coefficient and a Boundary Case

A hypothetical rating model has two orthogonal, centered predictors. Under the objective above, their normalized squared norms are \(q_1=2\) and \(q_2=0.5\), and their ordinary least-squares coefficients are \(\widehat{\beta}^{\,LS}_1=-0.50\) and \(\widehat{\beta}^{\,LS}_2=0.80\). For \(\lambda=0.40\), find both lasso coefficients. The method is coordinate-wise soft-thresholding; the key trap is mishandling the sign of the negative coefficient.

Step 1: Calculate the thresholds. For predictor 1, \(\lambda/q_1=0.40/2=0.20\). For predictor 2, \(\lambda/q_2=0.40/0.5=0.80\).

Step 2: Update the negative coefficient. Its least-squares magnitude is \(0.50\), which exceeds \(0.20\). Its sign remains negative, and its updated magnitude is \(0.50-0.20=0.30\). Therefore \(\widehat{\beta}^{\,lasso}_1=-0.30\).

Step 3: Update the positive coefficient. Its magnitude is exactly its threshold, \(0.80\). Therefore \(\widehat{\beta}^{\,lasso}_2=0\).

Check. The first estimate has the original negative sign and is closer to zero; the second lies at the zero boundary. The answer is \((-0.30,0)\).

Common mistake and correction. For the first coefficient, one might write \(-(-0.50+0.20)=+0.30\). That incorrectly changes the sign: the negative-side stationary value is \(\widehat{\beta}^{\,LS}_1+\lambda/q_1=-0.50+0.20=-0.30\). Equivalently, apply the sign of the least-squares estimate to the reduced magnitude. The corrected coefficient is \(-0.30\), not \(+0.30\).

Worked Example: Using Predictor-Response Inner Products

In a hypothetical claim-severity regression with two orthogonal centered predictors, the normalized squared norms are \(q_1=4\) and \(q_2=1\). The normalized predictor-response inner products are \(z_1=0.40\) and \(z_2=-0.90\), where \(z_j=x_j^\mathsf{T}y/n\). At \(\lambda=0.50\), calculate the lasso coefficients. The method is to recover the least-squares coefficients from \(z_j/q_j\), then threshold them.

Step 1: Recover the ordinary least-squares coefficients. For predictor 1, \(\widehat{\beta}^{\,LS}_1=z_1/q_1=0.40/4=0.10\). For predictor 2, \(\widehat{\beta}^{\,LS}_2=z_2/q_2=-0.90/1=-0.90\).

Step 2: Calculate the thresholds. They are \(0.50/4=0.125\) and \(0.50/1=0.50\).

Step 3: Apply the rule. The first magnitude, \(0.10\), is below \(0.125\), so \(\widehat{\beta}^{\,lasso}_1=0\). The second magnitude, \(0.90\), exceeds \(0.50\), so its sign stays negative and its updated magnitude is \(0.90-0.50=0.40\). Thus \(\widehat{\beta}^{\,lasso}_2=-0.40\).

Check. The lasso coefficients are \((0,-0.40)\). The larger \(q_1\) gives predictor 1 a smaller threshold than predictor 2, but the first least-squares coefficient is still too small to survive its threshold.

Common mistake to avoid. Treating \(z_j\) itself as the least-squares coefficient would give the wrong starting values. The coefficient is \(z_j/q_j\); the stated \(z_j\) is the normalized inner product, not the coefficient.

Worked Example: Comparing Two Penalty Values

A hypothetical predictive model has one centered predictor with \(q=1.5\) and ordinary least-squares coefficient \(\widehat{\beta}^{\,LS}=1.20\). Find the lasso coefficient at \(\lambda=0.45\), and then find the smallest penalty at which the coefficient becomes zero. State why the zero boundary is included.

Step 1: Calculate the threshold at \(\lambda=0.45\). It is \(0.45/1.5=0.30\).

Step 2: Update the coefficient. The least-squares coefficient is positive and its magnitude exceeds \(0.30\), so \(\widehat{\beta}^{\,lasso}=1.20-0.30=0.90\).

Step 3: Find the zero boundary. The coefficient is zero when \(|\widehat{\beta}^{\,LS}|\le\lambda/q\). Rearranging gives \(\lambda\ge q|\widehat{\beta}^{\,LS}|=1.5(1.20)=1.80\). At \(\lambda=1.80\), the threshold is exactly \(1.80/1.5=1.20\), so the coefficient is already zero.

Check. At \(\lambda=0.45\), the coefficient is \(0.90\); the first penalty value at which it is zero is \(1.80\). A larger penalty also leaves it at zero.

Common mistake to avoid. The threshold is not \(\lambda q\). With the objective specified here, it is \(\lambda/q\), so the zero boundary follows from \(q|\widehat{\beta}^{\,LS}|\le\lambda\).

What the Rule Does—and When It Does Not Apply

The formula separates two effects of the lasso penalty. First, it performs selection: any least-squares coefficient at or below its threshold is set exactly to zero. Second, for a coefficient that survives, it performs shrinkage: its magnitude is reduced by \(\lambda/q_j\), without changing its sign. At \(\lambda=0\), the threshold is zero and the lasso coefficients equal the least-squares coefficients. As \(\lambda\) increases, the threshold increases, so more coordinates can be set to zero.

The norm term \(q_j\) affects the threshold. For the same \(\lambda\), a predictor with larger \(q_j\) has a smaller threshold \(\lambda/q_j\) when coefficients are expressed in the scale used by the objective. This is one reason predictor scaling and the penalty convention must be clear before comparing coefficient updates. The calculation assumes the stated \(q_j\) values; it does not imply that predictors with different units are automatically comparable.

The key condition for the coordinate-wise formula is orthogonality. If predictors are correlated, the residual sum of squares contains cross-terms involving different coefficients, so minimizing for one coefficient while holding others fixed does not generally yield the displayed formula using the original least-squares coefficient. Coordinate-descent algorithms may use a soft-threshold step within an iteration, but its input is then a partial residual calculation; it is not the same as independently thresholding every original least-squares coefficient.

A second important condition is the objective’s scaling. For example, multiplying the residual sum of squares by a different constant while leaving \(\lambda\) unchanged changes the balance between fit and penalty. Therefore, before using a threshold, identify the exact objective, the definition of \(q_j\), and whether the intercept is penalized. These checks prevent a correct soft-thresholding idea from producing an incorrect numerical answer.

Key takeaway: With orthogonal predictors and objective \(\mathrm{RSS}/(2n)+\lambda\sum_j|\beta_j|\), calculate \(q_j=x_j^\mathsf{T}x_j/n\), then apply the threshold \(\lambda/q_j\) to the ordinary least-squares coefficient. Values equal to the threshold become zero; surviving values retain their sign and lose the threshold amount in magnitude.

Check Your Understanding

For each problem, use the objective and notation defined above. Answers are given after each item for checking.

  1. A centered orthogonal predictor has \(q=2\), ordinary least-squares coefficient \(0.45\), and penalty \(\lambda=0.30\). Find its lasso coefficient. (Answer: \(0.30\))
  2. A predictor has \(q=0.5\), ordinary least-squares coefficient \(-1.20\), and \(\lambda=0.40\). Find its coefficient and state whether it is zero. (Answer: \(-0.40\); nonzero)
  3. Two orthogonal predictors have \(q_1=1\), \(q_2=4\), least-squares coefficients \(0.25\) and \(-0.30\), and \(\lambda=0.25\). Find the lasso coefficient pair. (Answer: \((0,-0.2375)\))
  4. For two orthogonal predictors, \(q_1=2\), \(q_2=5\), and normalized inner products \(z_1=1.40\), \(z_2=-0.50\). With \(\lambda=0.40\), find the lasso coefficients. (Answer: \((0.50,-0.02)\))
  5. A single orthogonal predictor has \(q=3\) and least-squares coefficient \(-0.60\). What is the smallest \(\lambda\) at which its lasso coefficient is zero? What is the coefficient at that boundary? (Answer: \(\lambda=1.80\); coefficient \(0\))
Clinical Biostats