Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Calculus I With Integrated Precalculus

Authors: Laura Taalman

1st Edition

1464153027, 9781464153020

More Books

Students also viewed these Mathematics questions