We will run an out-of-sample experiment to see how well cross-validated
lasso performs. First, draw a random sample of size n = 8, 000 from the original 10, 000
observations, without replacement. We will refer to these observations X1, . . . , Xn and
Y1, . . . , Yn as the “estimation” sample. We will refer to the remaining m = 2, 000
observations Xn+1, . . . , Xn+m and Yn+1, . . . , Yn+m as the “holdout” sample.
Question 1.
Run 5-fold cross-validated lasso of log(yspend) on xweb on the estimation sample of n = 8, 000 observations. Report a plot of the out-of-sample
cross validation error as a function of λ (you can use the plot command on the
cv.gamlr object as in the lecture notes).
Please using R software and provide the related code file