We use lasso for prediction and model selection when we have many potential covariates. (And when we say many, we mean hundreds, thousands, or more!) We previously introduced the lasso
command to perform lasso for linear, logit, probit, and Poisson models. New in Stata 18 is lasso for Cox proportional hazards models. lasso cox
can be used to select covariates using lasso and fit a Cox model to survival-time data. elasticnet cox
can similarly be used to select covariates using elastic net and fit a Cox model.
After lasso cox
and elasticnet cox
, you can use predict
to predict the hazard ratio; use stcurve
to plot the survivor, hazard, or cumulative hazard functions; or use any of the other postestimation tools available after lasso
and elasticnet
to examine the lasso results.