Question: Problem 1 Consider the fat data from the faraway library in R. The following code is an example of how to select a random test


Problem 1 Consider the fat data from the faraway library in R. The following code is an example of how to select a random test set of 25 observations, and to use the remaining observations as the training set. In the code, we set the random seed to make the result reproducible, but this seed can be changed. library (faraway) n=dim (fat) [1] set . seed (12357) testid = sample(n, 25, replace=FALSE) trainid = -testid test = fat [testid, ] train = fat [trainid, ] We will compare several regression methods using train/test evaluation. a) For the fat data, create a randomly selected test set of 25 observations and a training set consisting of all the other observations, removing the variables brozek and density from the data. Display the first 6 rows of the training and test sets. Also display the dimensions of the training data frame and test data frame. Answer: b) Use the training data to estimate the linear regression of siri on all of the other variables except for brozek and density. Then use the test data to compute the estimated meansquare error for prediction. Answer: c) Repeat exercise b) for linear regression with variables selected using the BIC criterion (leaps and bounds or stepwise) Answer: d) Repeat exercise b) for scaled principal components regression, where you keep enough components to account for 90% of the variation in predictor variables. Answer: e) Repeat exercise b) for Lasso regression, where the amount of shrinkage is selected by 10-fold cross-validation
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
