Question: show all the r code step and detail step 6. R code exercise (a) Use the rnorm() function to generate a predictor X of length

show all the r code step and detail step show all the r code step and detail step 6. R
6. R code exercise (a) Use the rnorm() function to generate a predictor X of length n=100,X= 0,X=1, as well as a noise vector of length n=100,=0,=0.1. (b) Generate a response vector Y of length n=100 according to the model Y= 1+X+X2+X3+ (c) Fit a lasso model to the simulated data, using X,X2,,X10 as predictors. Use cross-validation to select the optimal value of . Create plots of the crossvalidation error (i.e. Mean-Square error v.s. log() ) as a function of . Report the resulting coefficient estimates. (d) Now re-generate a response vector Y according to the new model Y=1+X7+. Again, re-fit a lasso model using X,X2,,X10 as predictors. Use cross-validation to select the optimal value of . Create plots of the cross-validation error (i.e. Mean-Square error v.s. log()) as a function of . Report the resulting coefficient estimates. (Note: You will see that when the true data-generating model is sparser, cross-validation tends to select a sparser model.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related General Management Questions!