Why Convergence Needs More Than a Small Change
An iterative algorithm can make very small changes to its objective and coefficients without being close to the penalized optimum. This can happen when progress becomes slow, when a coordinate update is inaccurate, or when a stopping rule is poorly scaled. Conversely, a coefficient can change noticeably during an early iteration even when the algorithm is moving correctly toward a solution. A reliable convergence check therefore asks whether the current fit satisfies the optimality conditions, not only whether the last update was small.
For penalized GLMs, the lasso part of the penalty is not differentiable at zero. The relevant optimality check is consequently coordinatewise: a nonzero coefficient must satisfy a signed stationarity equation, while a zero coefficient must satisfy an inequality. This distinction is particularly useful for detecting a coefficient that an algorithm has set to zero even though it should not be inactive.
Objective and KKT Conditions
Let \(\beta=(\beta_0,\beta_1,\ldots,\beta_p)\) be an unconstrained coefficient vector, with \(\beta_0\) an unpenalized intercept. Let \(L(\beta)\) be a differentiable convex negative log-likelihood or other smooth convex loss, and let \(\lambda\geq 0\) and \(0\leq\alpha\leq1\). The elastic-net objective is
The coordinatewise smooth derivative, including the differentiable ridge contribution, is
Write \(t=\lambda\alpha\) for the lasso threshold. When \(\beta_j\neq0\), the derivative of \(|\beta_j|\) is \(\operatorname{sign}(\beta_j)\). At zero, its subgradient is the interval \([-1,1]\). These facts give the following conditions.
Two Results That Make the Residual Useful
A coordinatewise residual measures how far the current fit is from satisfying the appropriate condition. For a nonzero coordinate, measure the absolute stationarity error. For a zero coordinate, measure the distance of \(q_j\) from the permitted interval \([-t,t]\). Include the intercept derivative as well:
This is a first-order optimality diagnostic: it is zero exactly when all the displayed KKT conditions hold. The next result also explains why those conditions characterize a global solution here.
Proof. For necessity, if \(\beta\) is a minimizer, varying the unconstrained intercept in either direction gives \(q_0=0\). For a penalized coordinate with \(\beta_j\neq0\), sufficiently small perturbations in both directions preserve its sign. The derivative of the objective along that coordinate must therefore be zero, giving \(q_j+t\operatorname{sign}(\beta_j)=0\). If \(\beta_j=0\), the right directional derivative is \(q_j+t\), and the left directional derivative is \(-q_j+t\). At a minimum both must be nonnegative. Thus \(q_j\geq-t\) and \(q_j\leq t\), which is exactly \(|q_j|\leq t\).
For sufficiency, assume the conditions hold. For every nonzero coordinate choose \(s_j=\operatorname{sign}(\beta_j)\). For a zero coordinate, the inequality \(|q_j|\leq t\) allows a choice \(s_j=-q_j/t\in[-1,1]\) when \(t>0\); if \(t=0\), it implies \(q_j=0\), and choose \(s_j=0\). In each case \(s_j\) is a subgradient of \(|\beta_j|\) and \(q_j+ts_j=0\). Together with \(q_0=0\), this says that zero belongs to the subgradient of the convex function \(J\) at \(\beta\). The subgradient inequality then gives \(J(\gamma)\geq J(\beta)\) for every \(\gamma\in\mathbb{R}^{p+1}\). Hence \(\beta\) is a global minimizer. Finally, each residual is nonnegative and equals zero exactly when its corresponding KKT condition holds, so \(R_\infty=0\) is equivalent to the full set of conditions. \(\square\)
Worked Examples: Interpreting KKT Residuals
Worked Example: An Active Elastic-Net Coefficient
Suppose \(\lambda=0.5\), \(\alpha=0.4\), and a fitted penalized coefficient is \(\beta_1=0.3\). At this fit, let \(\partial L/\partial\beta_1=-0.37\). Calculate the signed stationarity residual.
First, \(t=\lambda\alpha=0.5(0.4)=0.20\), and the ridge contribution to \(q_1\) is \(\lambda(1-\alpha)\beta_1=0.5(0.6)(0.3)=0.09\). Thus \(q_1=-0.37+0.09=-0.28\). Since \(\beta_1>0\), the required stationarity equation is \(q_1+t=0\), and the residual is
The coefficient is active and its condition is not met exactly. Whether \(0.08\) is acceptable depends on the fitting scale and tolerance; it is not zero merely because the coefficient has the expected positive sign.
Worked Example: Checking Whether a Zero Coefficient Is Permitted
At a current fit, suppose \(\lambda\alpha=0.8\), \(\beta_2=0\), and the smooth derivative for that coordinate is \(q_2=-0.6\). Is the coordinate KKT condition satisfied?
The allowed interval is \([-0.8,0.8]\), and \(-0.6\) lies inside it. Therefore the coefficient satisfies its inactive-coordinate KKT condition, and its KKT residual is
For clarity, the expression \(\bigl(-0.6+0.8+|{-0.6-0.8}|\bigr)/2\) evaluates to \((0.2+1.4)/2=0.8\). That value is not the inactive-coordinate KKT violation: it is not the distance from \(q_2\) to \([-0.8,0.8]\). The correct KKT residual is zero, because the condition is satisfied. Using \(0.8\) as the violation would incorrectly label this coefficient as improperly inactive.
Worked Example: Detecting an Incorrectly Inactive Coefficient
Now retain \(t=0.8\) and \(\beta_2=0\), but suppose \(q_2=-1.1\). The inactive condition fails because \(|-1.1|=1.1>0.8\). The residual is
The negative derivative indicates that, before accounting for the lasso threshold, moving in the positive coefficient direction can reduce the smooth loss strongly enough to overcome the penalty. The coefficient should not be accepted as inactive at this fit. An algorithm should revisit the coordinate or continue iterating; simply reporting that \(\beta_2=0\) is not evidence that the zero is optimal.
Using Objective and Coefficient Changes Alongside KKT Checks
Objective and coefficient changes remain useful diagnostics, but neither is a substitute for the KKT residual. If an algorithm generates iterates \(\beta^{(k)}\), common scale-aware summaries are
A small \(\Delta_J^{(k)}\) says only that the objective changed little on this iteration. A small \(\Delta_\beta^{(k)}\) says only that the coefficients moved little. Either can occur while an inactive coordinate violates its KKT inequality. For example, a coordinate may not have been updated in the latest sweep; its coefficient change is then zero, even though its KKT residual remains positive. Small changes are useful stopping evidence only when paired with a sufficiently small KKT residual.
A practical stopping rule sets tolerances appropriate to the scale of the objective, coefficients, and derivatives. It might require a small relative objective change, a small relative coefficient change, and \(R_\infty\leq\varepsilon_{\mathrm{KKT}}\). Derivatives can have different numerical scales if the loss is rescaled, so the KKT tolerance should be interpreted in that same scale. For sparse fits, inspect the largest coordinate residual and whether it belongs to an active or inactive coordinate; the location often identifies what the algorithm has not resolved.
Check for unexpected increases, stagnation, and large coefficient movements. Treat these as warnings or supporting evidence, not as optimality certificates.
At the current coefficients, calculate \(q_0\) and each penalized \(q_j\), including the ridge contribution when \(\alpha<1\).
Use the signed equation for nonzero coefficients and the interval test for zero coefficients; then calculate \(R_\infty\).
If the KKT residual is too large, continue iterating or check derivative calculations, update rules, and stopping tolerances. In particular, reconsider zero coordinates with large residuals.
Common Pitfalls and Why the Check Matters
- Stopping because the objective barely changed. A flat or slowly improving iteration can still be far from satisfying stationarity. Check KKT residuals before declaring convergence.
- Using the active equation at zero. At \(\beta_j=0\), there is no single lasso derivative to insert. The correct condition is \(|q_j|\leq t\), not \(q_j+t\operatorname{sign}(0)=0\).
- Ignoring the ridge derivative. For an elastic-net fit, \(q_j\) includes \(\lambda(1-\alpha)\beta_j\). Leaving it out misstates the active-coordinate equation whenever the ridge component is nonzero.
- Applying unconstrained KKT conditions to a constrained fit. The proof above uses perturbations in both directions in the full parameter space. If coefficients are constrained, boundary optima require conditions that account for those constraints.
- Treating a zero coefficient as automatically valid. Zero is a valid optimum only when its smooth derivative lies within the lasso subgradient interval.
KKT-based checks matter because they test the local optimality conditions that characterize a global minimum for this convex objective. They are especially valuable for sparse fits: an incorrectly inactive coefficient can be missed by a coefficient-change check, while its KKT residual directly reveals that its zero value is not optimal. In numerical computation, use a stated tolerance rather than expecting exact zeros, and examine the residuals alongside objective and coefficient changes.
Check Your Understanding
Use the KKT conditions and residual definitions to answer the following questions.
- For a zero coefficient with \(t=0.4\) and \(q_j=0.25\), calculate the KKT residual and state whether the inactive condition holds.
- For a nonzero negative coefficient, write the correct signed stationarity equation.
- Why can a zero coefficient change between consecutive iterations be small even when the fit has not converged?
- In the elastic-net objective, which part of \(q_j\) accounts for the ridge penalty?
- What must be added or changed when the coefficient space is constrained rather than all of \(\mathbb{R}^{p+1}\)?