Warning! The page was not fully loaded, probably because of a network issue. It could be that not all functionalities work as expected. Please try reloading the page.
Questions
- Now fit a lasso model to the simulated data from the previous exercise, again using \(X,X^2,\cdots,X^{10}\) as predictors.
Don’t forget to load the necessary package(s) and make use of the
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:
- The
glmnet library has been loaded
- The
stats library has been loaded