Motivation
A regression model may contain many candidate features even though a useful description needs only a few of them. Least squares measures the quality of the fitted responses, but it does not directly express a preference for using fewer features. LASSO introduces a coefficient penalty whose corner at zero can remove some coefficients exactly. Matching pursuit approaches sparse approximation through a different decision: choose one useful direction at a time and record what remains unexplained.
These ideas share residuals and correlations, but they solve different mathematical problems. A small residual certifies a good fit to the observed response. A LASSO solution must additionally balance that fit against its coefficient penalty. A greedy sequence can be understood by inspecting each update, whereas a global minimizer needs an optimality condition involving every feature. Keeping these conditions separate makes each method easier to calculate and interpret.
Feature scaling is part of the model. Replacing one column by a large multiple allows its coefficient to become correspondingly smaller without changing its contribution to the fitted response. An absolute coefficient penalty therefore depends on the units used for the features. Centering and scaling selected from the training observations give the penalty a definite meaning; the same transformation is then applied to later observations.
Definitions
Definition
The LASSO objective
Let be a fixed feature matrix, a response vector, and . We minimize
The residual is . In this definition every coefficient is penalized.
The factor determines the threshold that will appear below. Removing it while keeping the same numerical changes the problem. Likewise, dividing the squared loss by the number of observations changes the relative strength of a fixed penalty. An unpenalized intercept is a separate parameter: its stationarity condition is , and its coefficient is not put through a threshold. The examples here have no extra intercept.
The function is convex because both terms are convex. Since , it grows without bound as the coefficient vector grows without bound, so a minimizer exists. Independent columns make the squared loss strictly convex and hence give uniqueness. Dependent columns do not justify a general uniqueness claim.
Definition
Dictionary atoms and a pursuit state
In a pursuit calculation the nonzero columns are called atoms. A state consists of coefficients and a residual satisfying . Ordinary matching pursuit starts at , , and repeatedly adds a multiple of one atom. An atom may be selected again.
Theorem/proposition
Proposition
LASSO optimality through residual correlations
A vector minimizes exactly when, for every ,
Thus a zero coefficient is compatible with an interval of correlations, rather than requiring the corresponding correlation to vanish.
Proposition
Soft thresholding for orthonormal features
If and , the unique LASSO minimizer is
Here . Correlations with magnitude at most produce zero coefficients; larger magnitudes are reduced by .
Proposition
Exact energy decrease in an ordinary matching-pursuit step
For a nonzero atom and current residual , the multiple minimizing is . The new residual obeys
The greatest one-step decrease comes from maximizing the displayed quotient. For unit atoms this is equivalent to maximizing .
The first condition also identifies where an entire coefficient vector becomes zero. At the residual is , so all zero-coordinate conditions hold exactly when . This gives a useful starting value for examining a range of penalties. As the penalty is decreased below that level, the zero vector ceases to satisfy at least one correlation condition. The condition describes the chosen training problem; selecting a penalty for prediction still requires evaluating models on observations excluded from their fitting calculations. It is not determined by the number of zero coefficients alone.
The interval at zero is essential to this behavior. For a squared coefficient penalty the derivative at zero is a single value, whereas the absolute value can balance a whole interval of nonzero loss gradients. This explains why thresholding is a structural feature of the penalty, rather than a numerical rounding rule applied after a dense fit has been computed.
Proof sketch or proof idea
The gradient of the squared-loss term with respect to is . For a positive coefficient the derivative of is ; for a negative coefficient it is . At zero its supporting slopes form . The convex optimality condition is consequently , which gives the first proposition. Convexity makes this condition sufficient as well as necessary: a zero supporting slope means that moving to any other vector cannot lower the objective.
For orthonormal columns, expansion separates the coordinates:
For one coordinate , a positive minimizer must satisfy , which lies on the positive side only if . A negative minimizer must satisfy , which lies on the negative side only if . In the remaining interval the left derivative at zero is nonpositive and the right derivative is nonnegative, so zero minimizes the coordinate function. This derives all three cases, including the boundaries.
Finally, expand an ordinary pursuit step as and complete the square. The positive coefficient gives a unique minimizing increment. Substitution proves the energy identity and orthogonality to the chosen atom. Neither statement requires the other atoms to be orthogonal to that atom.
Worked examples
Worked example
Example 1: A coefficient disappears at the threshold
Take , , and . The correlations are the response entries, so soft thresholding gives
Indeed, the squared-loss term is and the penalty is . The first residual correlation equals , as required for a positive coefficient. The second equals , which belongs to the permitted interval for a zero coefficient. Equality at its endpoint does not force that coefficient to be negative.
The zero vector has objective , while the unpenalized fit has objective . The minimizer lies between these choices by balancing fit and coefficient size. If instead, the solution is ; its objective is . These are different objectives, so their numerical minima are not a common measure for selecting .
Worked example
Example 2: An atom is useful more than once
Let , , and . Both atoms have unit length. Initially the correlations are and , so the first step selects . After three ordinary matching-pursuit steps we obtain
The squared residual norms are , , , and . At the second step the increment on is . It removes the first residual coordinate but makes the residual correlated with again. The third increment on is , which must be added to its existing coefficient. Overwriting that coefficient would break .
Worked example
Example 3: Refitting the selected span changes the answer
After selecting the two atoms above, orthogonal matching pursuit refits both coefficients jointly by least squares. Solving and gives
Ordinary matching pursuit after two steps instead has coefficients and squared residual norm . Refitting uses the whole selected span; it is not another name for subtracting the newest atom.
Exact fitting also differs from LASSO optimality. With , the OMP vector has . The two-step MP vector has , which is smaller despite its nonzero residual. This comparison does not certify the MP vector as a LASSO solution; it shows why a residual-only stopping argument cannot certify that objective.
Coordinate updates and greedy updates
For a general feature matrix, the orthonormal soft-threshold formula does not apply to all coordinates simultaneously. There is nevertheless an exact one-coordinate update for a nonzero column . Hold the other coefficients fixed and define . This adds back the current contribution of feature , leaving the response that this coordinate is allowed to explain. Minimizing gives
This updates an entire coefficient. Penalizing only a proposed increment by defines a different one-step objective when the atom has already been used: the global penalty involves . Residual correlations can verify the LASSO conditions after a computation, independently of the algorithm used to obtain its coefficients.
To see why the denominator has this form, put and . Up to a term independent of , the coordinate objective is . The positive and negative stationary equations are and respectively, with zero filling the interval between them. Each coordinate subproblem is therefore strictly convex even if the full feature matrix has dependent columns. For a zero column the coefficient is set directly to zero by minimizing its penalty.
A pursuit residual whose correlations vanish for every atom is already perpendicular to the entire available feature space. It then satisfies the ordinary least-squares normal equations, even when its length is positive: the unexplained component lies outside that space. Before that stage, the energy identity measures a possible improvement. In Example 2 the successive energies keep halving, so approaching an exact representation does not require reaching it in finitely many ordinary MP steps. A prescribed number of steps selects a point in this sequence; it is a separate modelling choice from selecting the coefficient penalty in LASSO.
The following code traces the ordinary pursuit in Example 2. It chooses by the energy decrease, so the expression remains correct for non-unit atoms.
import numpy as np
A = np.array([[1.0, 1.0 / np.sqrt(2.0)],
[0.0, 1.0 / np.sqrt(2.0)]])
y = np.array([0.0, 1.0])
beta = np.zeros(2)
residual = y.copy()
norm2 = np.sum(A * A, axis=0)
for step in range(3):
correlation = A.T @ residual
j = int(np.argmax(correlation ** 2 / norm2))
increment = correlation[j] / norm2[j]
beta[j] += increment
residual -= increment * A[:, j]
energy = float(residual @ residual)
print(f"{step + 1}: atom={j + 1}, beta=({beta[0]:.6f}, {beta[1]:.6f}), energy={energy:.6f}")
omp, _, _, _ = np.linalg.lstsq(A, y, rcond=None)
assert np.allclose(omp, [-1.0, np.sqrt(2.0)])
1: atom=2, beta=(0.000000, 0.707107), energy=0.500000
2: atom=1, beta=(-0.500000, 0.707107), energy=0.250000
3: atom=2, beta=(-0.500000, 1.060660), energy=0.125000
Penalized pursuit increments
A pursuit step can penalize the amount added to a coefficient. To derive this version, use a squared loss without the factor and define
This normalization has threshold . Starting with and , choose a nonzero atom, write and , and minimize the one-variable increment objective
The residual in this expression is the current residual: the old contribution of the chosen atom has not been added back. The penalized quantity is the new increment, not the entire updated coefficient.
Proposition
A penalized increment and its exact local improvement
The unique minimizing increment is
Its local objective improvement is
On the positive side, differentiating gives ; that candidate is positive only when . The negative-side equation gives the opposite branch. At zero, the supporting-slope interval contains zero exactly when . Substituting the consistent branch into the expanded quadratic proves the improvement formula. Comparing only the two nonzero stationary expressions would miss this interval.
For example, with , , and , the correct increment is zero and . The expressions and lie outside their respective sign branches; their objective values are and . Neither replaces the zero solution.
Choosing the largest gives the greatest decrease in this local increment objective. For unit atoms, or any common positive , selecting a largest also maximizes . Unequal norms require the displayed denominator. If all scores vanish, every proposed increment is zero. After selecting an atom, preserve the pursuit invariant by
Repeated selections accumulate; the coefficient is not overwritten. Unlike ordinary MP, a nonzero penalized step leaves a threshold-sized correlation with its selected atom, rather than making that correlation zero.
For a concrete unequal-norm comparison, take , atoms and , and . Their raw correlations are and , but the respective improvements are and . Thus the larger raw correlation gives the smaller local improvement. The score compares the atoms in their specified scales; normalizing columns also requires interpreting the coefficient penalty in the new units.
The global penalty change is , whereas charges . Writing for the th coordinate unit vector, the triangle inequality therefore gives
Thus a correctly minimized increment cannot increase the global objective. The two changes agree for a previously unused coefficient, but need not agree after reuse. In particular, is not generally the exact global improvement. If an increment shrinks an existing coefficient without crossing zero, its global penalty decreases while the increment penalty is positive. The inequality makes a lower bound on the global decrease; maximizing it optimizes the local score, not necessarily the actual global decrease. Full coordinate minimization instead adds back the old contribution and replaces the entire coefficient:
Worked example
Example 4: Penalized increments can stall before LASSO optimality
Use the unit-column matrix and response
The initial correlations are , so the first step selects atom 1. The next correlations are , so atom 2 is selected next. The trace records increments as well as accumulated coefficients:
After step 2, the correlations are . Both scores vanish; the largest-correlation rule selects atom 2 again and produces zero. However, the positive first coefficient requires correlation for optimality, not . Full coordinate minimization would set , already decreasing the objective by .
The actual global solution is , with residual . Both positive-coordinate correlations equal , verifying its optimality. Its objective is , below the stalled value . These values are and , respectively: squared residual norm plus coefficient penalty. Since the two columns are independent, the verified global minimizer is unique for this particular matrix. The example separates decreasing an increment objective from minimizing a full coordinate: even a zero-improvement stopping state can fail the global coefficient conditions.
Constraints and smooth penalties
Let minimize LASSO and set . It also minimizes the squared loss over . Otherwise a feasible vector with smaller loss would have no larger penalty, contradicting penalized optimality. This constructs a constrained problem from a particular penalized solution. It does not establish a one-to-one relation between and ; several penalty values can give the same zero solution.
A smooth alternative replaces the absolute value by a rounded function. One normalized Huber penalty is
Its outer slope is one and as . A normalized pseudo-Huber penalty provides another rounding:
The normalized derivatives make their smoothness precise:
At , the Huber first derivatives agree, but the second derivative changes from to zero. Thus Huber is continuously differentiable, not twice differentiable there. Pseudo-Huber is smooth everywhere. Both have curvature at zero and limiting outer slope of magnitude one. Using or instead multiplies the penalty contribution by at fixed ; specify this scale together with the smoothing width.
For , consider . Inside the quadratic region, gives . It belongs to that region precisely when . Outside it, the stationary equation is . Its consistent branch gives
At , both expressions give . The quadratic loss is strictly convex and the penalty is convex, so this stationary point is the unique global minimizer. For either smoothed penalty, the scalar objective has derivative at zero. Its minimizer is therefore zero exactly when , unlike LASSO's interval of exact zeros. Here the smoothing is applied to coefficients; replacing a residual loss by Huber defines a different regression objective.
Common mistakes
Common mistake
Treating correlation, refitting, and optimality as the same test
For non-unit atoms, the largest raw correlation need not give the greatest residual-energy decrease; divide its square by the atom's squared norm. An ordinary MP residual is perpendicular to the most recently selected atom, whereas an OMP least-squares residual is perpendicular to every selected column. Neither observation alone checks the LASSO penalty conditions on all columns.
Coefficient sparsity is also representation-dependent. Two highly related features may exchange their contributions while leaving fitted responses similar. A selected feature is part of a model with specified units and a specified penalty, rather than a conclusion about causation.
For an exact illustration, take , response , and . Writing , the triangle inequality gives . The scalar optimum is , and every vector with attains the same objective . Some of these vectors have one nonzero coefficient and others have two. The fitted response is the same throughout, while the feature representation is ambiguous. This is why coefficient uniqueness cannot be inferred simply from the use of an absolute-value penalty.
Summary
The corner of the absolute-value penalty permits exact zero coefficients. Soft thresholding makes that mechanism explicit for orthonormal features and for individual coordinate subproblems. Ordinary matching pursuit instead controls the change in residual energy one atom at a time. Refitting the selected span produces OMP, while testing all residual correlations against the penalty conditions checks LASSO optimality.
Exercises
Checkpoint
Exercise 1: Let , , and . Find the LASSO coefficients, residual, and objective value.
Apply soft thresholding to every response entry, including the middle one.
Checkpoint
Exercise 2: For residual , compare atoms and . Which maximizes raw correlation, and which removes more squared residual energy?
Calculate the correlation squared divided by the squared atom norm.
Checkpoint
Exercise 3: In Example 2, compute the fourth MP increment, coefficients, and squared residual norm.
Start with residual and compare its two correlations.
Checkpoint
Exercise 4: A scalar LASSO problem has , , and . Check the candidate coefficient . What fails if one considers only nonzero stationary candidates?
The absolute value has an interval of supporting slopes at zero.
Checkpoint
Exercise 5: For , take and . Find the minimizers for and . Compare the first with scalar LASSO.
The boundary between the two solution branches is .
Solutions
Solution · Exercise 1 solution
The coefficients are and the residual is . The objective is . The residual correlations of the two zero coordinates lie inside .
Solution · Exercise 2 solution
The raw correlations are and , but the energy decreases are and . Atom removes the entire residual, whereas atom removes only its first coordinate. Normalizing the selection score avoids a preference caused merely by the atom's length.
Solution · Exercise 3 solution
The correlations are with and zero with , so the fourth increment is on . The coefficients become and the residual becomes . Its squared norm is .
Solution · Exercise 4 solution
At zero, and the correlation belongs to , so the convex optimality condition holds. The positive-side equation proposes , outside that side; the negative-side equation proposes , outside its side. Those invalid candidates do not replace the zero case. The actual objective at zero is .
Solution · Exercise 5 solution
The branch boundary is . For , the quadratic-region formula gives , which is inside . Scalar LASSO instead gives . For , both formulas give : the inner formula is and the outer one is . This checks the boundary as well as the nonzero effect of smoothing.
Related notes
Least squares and residuals develops the residual geometry used here. Model validation and ridge regression explains how a penalty is chosen and how a quadratic penalty changes fitting. SVD and principal components studies orthogonal directions in data. The course reading list groups the books for further study.