This question involves the use of simple linear regression on the Auto data set.
Make sure that you omit rows with missing values.
Some of the exercises are not tested by Dodona (for example the plots), but it is still useful to try them.
Use the lm() function to perform a simple linear regression with
mpg as the response and horsepower as the predictor. Store the model in lm.fit.
Use the summary() function to print the results.
mpg associated with a horsepower of 102? (store answer in pred)What are the associated 95 % confidence and prediction intervals of the prediction with a horsepower of 102?
(store answers in conf.int.95 and pred.int.95)
horsepower hints at a weak relationship between horsepower and mpg.horsepower is negative, we can conclude that the more horsepower a car has,
the lower the mpg will be (on average).
Plot the response and the predictor. Use the abline() function
to display the least squares regression line.
plot() function to produce diagnostic plots of the least
squares regression fit. Comment on any problems you see with
the fit.Use the code below as a starting point.
Assume that:
ISLR2 library has been loadedAuto dataset has been loaded and attached