This question relates to the College data set, available in the ISLR2 package.
Some of the exercises are not tested by Dodona (for example the plots), but it is still useful to try them.
sample() function.
Take 50% of the data (388 rows) in the training set and the other 50% in the test set. Use a seed value of 1.
Store the indices of the training set in train. Use the indices to create College.train and College.test.Outstate as the response and the other variables as the predictors,
perform forward stepwise selection on the training set. Use the regsubsets() function from the leaps package.
Set the nvmax parameter to the total number of predictors, 17. Store the object in subset.fit.Call the summary() function on the object and inspect the attributes returning the adjusted \(R^2\), \(BIC\), and \(C_p\)
for each of the subsets.
subset.coef.
(Hint: you can call the coef() function with id parameter on the subset.fit object)
Outstate as the response and the following features (in this order please):
PrivateRoom.Board with df=2PhD with df=2Expend with df=5gam.fit.
Set par(mfrow = c(2, 2)) and plot the results. Reflect on your findings.
gam.preds.mse.Assume that:
ISLR2 library has been loadedCollege dataset has been loaded and attachedleaps library have been loadedgam library has been loaded