Penalties that shrink
Regularisation adds a penalty to a fitting loss so that large coefficients cost something: minw ∥y−Xw∥2+λΩ(w). Ridge uses Ω=∥w∥22 and the lasso uses Ω=∥w∥1. This is an optimization problem like any other, and it has an equivalent constrained form, min loss subject to Ω(w)≤t, in which λ is exactly the KKT multiplier of the budget t. A larger λ means a smaller budget.
wmin 21(w−z)2+λ∣w∣ ⇒ w=sign(z)max(∣z∣−λ,0),wmin 21(w−z)2+2λw2 ⇒ w=1+λz(1) The one-variable problems show the difference. Ridge divides the unpenalised value z by 1+λ: every coefficient shrinks by the same proportion but none reaches zero. The lasso subtracts λ from ∣z∣ and clips at zero, so every coefficient with ∣z∣≤λ becomes exactly zero. This is why the lasso selects variables. Geometrically, the ℓ1 ball has corners on the axes and the loss contours tend to touch it at a corner, while the round ℓ2 ball has no corners. Analytically, ∣w∣ has a kink at zero where the slope jumps from −λ to +λ, and a minimum can sit on that kink.
Numbers for both penaltiesTake
λ=1. For
z=3 the lasso gives
max(3−1,0)=2 and ridge gives
3/2=1.5. For
z=0.8 the lasso gives
0, because
0.8≤1, while ridge still gives
0.4. A full regression: for
x=(1,2) and
y=(1,3) we have
xTx=5 and
xTy=7, and ridge gives
w=7/(5+λ):
1.4 at
λ=0 and exactly
1 at
λ=2.
In finance the ridge penalty stabilises regressions on correlated predictors, a cousin of covariance shrinkage, and the lasso builds sparse index-tracking portfolios. One trap: in a long-only, fully invested portfolio ∑i∣wi∣=∑iwi=1, so the penalty λ∥w∥1 is the constant λ and changes nothing. To get few non-zero positions or few trades, penalise the trades ∥w−w′∥1, which is exactly what turnover and cost limits do in the capstone. In Bayesian terms ridge corresponds to a Gaussian prior on the coefficients and the lasso to a Laplace prior.
- Ridge: w=z/(1+λ) in one variable; shrinks smoothly, never exactly to zero.
- Lasso: soft threshold sign(z)max(∣z∣−λ,0); sets small coefficients exactly to zero.
- Constrained form: penalty weight λ is the KKT multiplier of the budget Ω(w)≤t.
Choose λ out of sampleA bigger λ trades variance for bias: coefficients get smaller and more stable but systematically pulled toward zero. Pick λ by cross-validation or a walk-forward test, never by the in-sample fit, which always prefers λ=0. With time series use blocks that respect time order. Lab · what's graded
- A lasso coefficient10 pts
- A ridge coefficient10 pts
- A coefficient set to zero15 pts
- A one-variable ridge regression15 pts
- Why the lasso makes exact zeros15 pts
- A useless penalty15 pts
- Priors and effects10 pts
- What a larger lambda does10 pts