🧮 Brain Teaser

Ridge Regression with Cloned Features

Let x∈RNx \in \mathbb{R}^N be a nonzero feature vector and y∈RNy \in \mathbb{R}^N a response. There is no intercept. Fix λ>0\lambda > 0.

(a) Ridge regression on the single feature xx, min⁡β ∥y−xβ∥2+λβ2,\min_{\beta}\ \|y - x\beta\|^2 + \lambda \beta^2, gives coefficient a=x⊤yx⊤x+λa = \dfrac{x^\top y}{x^\top x + \lambda}.

Now duplicate the feature: the design matrix becomes X=[ x∣x∣⋯∣x ]X = [\,x \mid x \mid \cdots \mid x\,], with mm identical columns. Refit ridge regression with the same λ\lambda: min⁡β∈Rm ∥y−Xβ∥2+λ∥β∥22.\min_{\beta \in \mathbb{R}^m}\ \|y - X\beta\|^2 + \lambda \|\beta\|_2^2 .

Show that all mm coefficients are equal, and find their common value. What is the total effect ∑iβi\sum_i \beta_i? Interpret the result in terms of an "effective" regularization parameter.

(b) Answer the same question for the lasso, where the penalty is λ∥β∥1\lambda\|\beta\|_1. Is the solution still unique?

Try to do (a) without differentiating anything.

ridge regressionlassosymmetrystrict convexitygrouping effectregularization

Answer: Ridge Regression with Cloned Features

Key Idea / Intuition

The loss sees only the sum s=β1+⋯+βms = \beta_1 + \cdots + \beta_m, because every column is the same vector xx. So the problem splits into two steps:

  1. For a fixed total effect ss, find the cheapest way to split it among the mm copies under the penalty.
  2. Optimize over ss.

The ℓ2\ell_2 penalty is strictly convex, so it prefers spreading the effect evenly. An even split costs only s2/ms^2/m, which means cloning a feature divides its effective ridge penalty by mm. The ℓ1\ell_1 penalty does not care how the effect is split, as long as all parts have the same sign. Hence the lasso solution is not unique.


Formal Proof / Solution

(a) Ridge

Symmetry argument for equal coefficients.

  • Since λ>0\lambda>0, the objective F(β)=∥y−Xβ∥2+λ∥β∥2F(\beta) = \|y - X\beta\|^2 + \lambda\|\beta\|^2 is strictly convex. It therefore has a unique minimizer β^\hat\beta.
  • Permuting the coordinates of β\beta permutes identical columns of XX. This leaves both XβX\beta and ∥β∥2\|\beta\|^2 unchanged, so F(σβ)=F(β)F(\sigma\beta) = F(\beta) for every permutation σ\sigma.
  • Hence σβ^\sigma\hat\beta is also a minimizer. By uniqueness, σβ^=β^\sigma\hat\beta = \hat\beta for all σ\sigma.
  • Therefore all coordinates are equal: β^1=⋯=β^m=:b\hat\beta_1 = \cdots = \hat\beta_m =: b.

Reduction to one variable.

Write s=∑iβis = \sum_i \beta_i. Then Xβ=xsX\beta = x s.

For fixed ss, the Cauchy–Schwarz (or QM–AM) inequality gives ∑i=1mβi2  ≥  s2m,\sum_{i=1}^m \beta_i^2 \;\ge\; \frac{s^2}{m}, with equality iff all βi=s/m\beta_i = s/m. This confirms the even split directly. The problem then becomes min⁡s ∥y−xs∥2+λm s2.\min_s\ \|y - xs\|^2 + \frac{\lambda}{m}\, s^2 .

This is single-feature ridge with penalty λ/m\lambda/m. Its solution is s^=x⊤yx⊤x+λ/m.\hat s = \frac{x^\top y}{x^\top x + \lambda/m}.

Answer. β^1=⋯=β^m=x⊤ym x⊤x+λ,∑iβ^i=x⊤yx⊤x+λ/m.\boxed{\hat\beta_1 = \cdots = \hat\beta_m = \frac{x^\top y}{m\,x^\top x + \lambda}}, \qquad \sum_i \hat\beta_i = \frac{x^\top y}{x^\top x + \lambda/m}.

For example, with m=2m=2 each copy gets x⊤y2x⊤x+λ\dfrac{x^\top y}{2x^\top x + \lambda}.

Interpretation.

  • Cloning a feature mm times is equivalent to fitting the original feature with ridge parameter λ/m\lambda/m.
  • Duplication therefore weakens shrinkage. The fitted total effect moves from aa toward the OLS value x⊤y/x⊤xx^\top y / x^\top x, and reaches it as m→∞m \to \infty.
  • Practical consequence: ridge is not invariant to redundant features. Highly correlated groups of predictors are collectively shrunk less, and their coefficients are spread evenly across the group. This is the "grouping effect".

(b) Lasso

For fixed ss, the triangle inequality gives ∑i∣βi∣≥∣s∣,\sum_i |\beta_i| \ge |s|, with equality iff all nonzero βi\beta_i share the sign of ss.

The problem therefore reduces to min⁡s∥y−xs∥2+λ∣s∣,\min_s \|y - xs\|^2 + \lambda |s|, which is the single-feature lasso with the same λ\lambda. Its solution is s^=sign⁡(x⊤y) (∣x⊤y∣−λ/2)+x⊤x.\hat s = \frac{\operatorname{sign}(x^\top y)\,\big(|x^\top y| - \lambda/2\big)_+}{x^\top x}.

Conclusions:

  • The total effect is unchanged by duplication.
  • Any split βi=wis^\beta_i = w_i \hat s with wi≥0w_i \ge 0 and ∑iwi=1\sum_i w_i = 1 is optimal. For s^≠0\hat s \ne 0 and m≥2m \ge 2 this is a whole simplex of solutions, so the solution is not unique.
  • In practice, an algorithm such as coordinate descent typically picks one copy arbitrarily and sets the others to zero.

This contrast motivates the elastic net. Adding a small ℓ2\ell_2 term restores strict convexity. The symmetry argument above then forces equal coefficients on identical features, recovering the grouping effect.

Reference: Hastie, Tibshirani & Friedman, The Elements of Statistical Learning (2nd ed.), Exercise 3.29 (ridge with an exact copy of a variable); see also §3.4.1 and the elastic net discussion in §18.4.

Source: The Elements of Statistical Learning (2nd ed.), Hastie, Tibshirani & Friedman, Exercise 3.29

Type: ML/StatsSource: The Elements of Statistical Learning (2nd ed.), Hastie, Tibshirani & Friedman, Exercise 3.29Edit on GitHub ↗