Skip to main content

Ridge — L2 regularized regression

Ridge adds an L2 penalty to the OLS objective to shrink coefficients toward zero, stabilizing estimates under multicollinearity or with many regressors (large p). Ridge does not set coefficients exactly to zero (no variable selection) but substantially reduces estimation variance.

When to use

Use Ridge when regressors are highly correlated (multicollinearity), making OLS unstable (inflated, sign-flipping coefficients). If you need variable selection, use Lasso.


Model specification

Ridge minimizes the residual sum of squares plus an L2 penalty:

minβ  i=1n(YiXiβ)2+λj=1pβj2\min_{\beta} \; \sum_{i=1}^{n} (Y_i - X_i \beta)^2 + \lambda \sum_{j=1}^{p} \beta_j^2

λ0\lambda \ge 0 is the regularization parameter: λ=0\lambda = 0 ⇒ OLS; larger λ\lambda ⇒ stronger shrinkage.


Choosing lambda & notes

  • Choose λ\lambda by cross-validation (CV).
  • Standardize variables first, since the penalty is scale-sensitive.
  • Ridge reduces variance but increases bias (bias-variance tradeoff).

Running in EcoLab

  1. Modeling module → Regularized regression family → Ridge.
  2. Select YY, the XX variables; enable standardization; choose λ\lambda (or auto CV).
  3. Run and read the shrunk coefficients and the shrinkage path; export the replication code.

Replication code

* ---- Ridge Regression ----
* Note: ridgereg is a community-contributed command
* Install: ssc install ridgereg
use "macro_data.dta", clear

ridgereg y x1-x20, model(orr)

Limitations

  • Does not select variables (all coefficients non-zero).
  • Coefficients are harder to interpret due to shrinkage; typically used for prediction rather than causal inference.

Video tutorial

Video Tutorial: Running Ridge regression in EcoLab

See also