ISLR Home

# Question

p122

This question involves the use of multiple linear regression on the Auto data set.

Produce a scatterplot matrix which includes all of the variables in the data set.

Compute the matrix of correlations between the variables using the function cor(). You will need to exclude the name variable, which is qualitative.

Use the lm() function to perform a multiple linear regression with mpg as the response and all other variables except name as the predictors. Use the summary() function to print the results. Comment on the output. For instance:

- Is there a relationship between the predictors and the response?
- Which predictors appear to have a statistically significant relationship to the response?
- What does the coefficient for the year variable suggest?

Use the plot() function to produce diagnostic plots of the linear regression fit. Comment on any problems you see with the fit. Do the residual plots suggest any unusually large outliers? Does the leverage plot identify any observations with unusually high leverage?

Use the * and : symbols to fit linear regression models with interaction effects. Do any interactions appear to be statistically significant?

Try a few different transformations of the variables, such as log(X), \(\sqrt{X}, X^2\). Comment on your findings.

```
library(ISLR)
library(tidyverse)
library(GGally)
library(car) # scatterplotMatrix
```

# 9a Scatterplot Matrix

Produce a scatterplot matrix which includes all of the variables in the data set.

## Basic Scatterplot Matrix

`pairs(Auto)`