Data Analysis

          In this exercise, we will generate simulated data, and will then use this data to perform best subset selection. (a) Use the morn() function to generate a ppoiictor X of length = 100. as well as a noise vector c of length n = 100. (b) Generate a response vector Y of length n = 100 according to the model = mo + fl1X +62X2 + (las+ r, where $0. h. and Os are constants of your choice. (c) Use the regsubsetsf) function to perform best subset selection In order to (bocce the best model containing the predictors X, X2 V10. What is the best model obtained according to C,, BIC, and adjusted R2? Show some plots to provide evidence for your answer, and report the coefficients of the best model ob-tained. Note you will need to use the data. tram() function to create a single data set containing both X and Y. (d) Repeat (c), using forward stepwise selection and also using back-wards stepwise selection. How does your answer compare to the results in (c)? (e) Now fit a lasso model to the simulated data, again using X, X3, . . . , X I° as predictors. Use cross-validation to select the optimal value of A. Create plots of the cross-validation error as a function of A. Report the resulting coefficient estimates, and discuss the results obtained. (f) Now generate a response vector Y according to the model Y = + flat + €, and perform best subset selection and the lasso. Discuss the results obtained.  

Comply today with Compliantpapers.com, at affordable rates

Order Now