Opgepast! De pagina kon niet volledig ingeladen worden, waarschijnlijk door een netwerkprobleem. Het kan zijn dat niet alle functionaliteit beschikbaar is. Probeer de pagina te verversen.
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