model.matrix
function.
Use cross-validation to select the optimal value of \(\lambda\), store this value in bestlam
.
Now build the model with the optimal lambda value and store the coefficient estimates in coef.lasso
.
Assume that:
glmnet
library has been loadedstats
library has been loaded