R Question
Description
Unformatted Attachment Preview
PSTAT Fall 2022
Due date: November 30th, 2022 at 23:59 PT
±. This question uses the Auto dataset available in the ISLR package. The dataset under the name Auto
is automatically available once the ISLR package is loaded.
library(ISLR)
data(Auto)
The dataset Auto contains the following information for 392 vehicles:
-pg: miles per gallon
#ylinders: number of cylinders (between 4 and 8)
$isplacement: engine displacement (cu.inches)
(orsepower: engine horsepower
7eight: vehicle weight (lbs)
!cceleration: time to accelerate from 0 to 60 mph (seconds)
9ear: model year
/rigin: origin of the vehicle (numerically coded as 1: American, 2: European, 3: Japanese)
.ame: vehicle name
Our goal is to analyze several linear models where mpg is the response variable.
(a) (2 pts) In this data set, which predictors are qualitative, and which predictors are quantitative?
(b) (2 pts) Explore the data and perform a descriptive analysis of each variable, include any plot/statistics
that you find relevant (histograms, boxplots, scatter diagrams, correlation coefficients). Comment on
your findings.
(c) (2 pts) Fit a MLR model to the data, in order to predict mpg using all of the other predictors except
for name. For each predictor in the fitted MLR model, comment on whether you can reject the null
hypothesis that there is no linear association between that predictor and mpg, conditional on the other
predictors in the model.
(d) (2 pts) What mpg do you predict for a Japanese car with three cylinders, displacement 100, horsepower
of 85, weight of 3000, acceleration of 20, built in the year 1980?
(e) (2 pts) On average, holding all other predictor variables fixed, what is the difference between the mpg
of a Japanese car and the mpg of an European car?
(f) (2 pts) Fit a model to predict mpg using origin and horsepower, as well as an interaction between
origin and horsepower. Present the summary output of the fitted model, and write out the fitted linear
model.
(g) (2 pts) Following the previous question: On average, how much does the mpg of a Japanese car change
with a one-unit increase in horsepower?
(h) (2 pts) If we are fitting a polynomial regression with mpg as the response variable and weight as the
predictor, what should be a proper degree of that polynomial?
(i) (4 pts) Perform a backward selection, starting with the full model which includes all predictors (except
for name). What is the best model based on the AIC criterion? What are the predictor variables in
that best model?
1
2. Use the fat data set available from the faraway package. Use the percentage of body fat: siri as the
response, and the other variables, except bronzek and density as potential predictors. Remove every
tenth observation from the data for use as a test sample. Use the remaining data as a training sample,
building the following models:
(a) (5 pts) Linear regression with all the predictors.
(b) (5 pts) Linear regression with variables selected using AIC and BIC. Include comparison plots and
comment on your findings.
(c) (5 pts) Ridge regression.
(d) (5 pts) Use the models you fit to predict the response in the test sample (provide point and interval
estimate). How do the models compare in terms of prediction (refer to both precision and accuracy)?
2
Purchase answer to see full
attachment
Have a similar assignment? "Place an order for your assignment and have exceptional work written by our team of experts, guaranteeing you A results."