In the exercises below we cover some material on multiple regression in R.

Answers to the exercises are available here.

If you obtained a different (correct) answer than those listed on the solutions page, please feel free to post your answer as a comment on that page.

We will be using the dataset `state.x77`

, which is part of the `state`

datasets available in `R`

. (Additional information about the dataset can be obtained by running `help(state.x77)`

.)

**Exercise 1**

a. Load the `state`

datasets.

b. Convert the `state.x77`

dataset to a dataframe.

c. Rename the `Life Exp`

variable to `Life.Exp`

, and `HS Grad`

to `HS.Grad`

. (This avoids problems with referring to these variables when specifying a model.)

**Exercise 2**

Suppose we wanted to enter all the variables in a first-order linear regression model with `Life Expectancy`

as the dependent variable. Fit this model.

**Exercise 3**

Suppose we wanted to remove the `Income`

, `Illiteracy`

, and `Area`

variables from the model in Exercise 2. Use the `update`

function to fit this model.

**Exercise 4**

Let’s assume that we have settled on a model that has `HS.Grad`

and `Murder`

as predictors. Fit this model.

**Exercise 5**

Add an interaction term to the model in Exercise 4 (3 different ways).

**Exercise 6**

For this and the remaining exercises in this set we will use the model from Exercise 4.

Obtain 95% confidence intervals for the coefficients of the two predictor variables.

**Exercise 7**

Predict the Life Expectancy for a state where 55% of the population are High School graduates, and the murder rate is 8 per 100,000.

**Exercise 8**

Obtain a 98% confidence interval for the mean Life Expectancy in a state where 55% of the population are High School graduates, and the murder rate is 8 per 100,000.

**Exercise 9**

Obtain a 98% confidence interval for the Life Expectancy of a person living in a state where 55% of the population are High School graduates, and the murder rate is 8 per 100,000.

**Exercise 10**

Since our model only has two predictor variables, we can generate a 3D plot of our data and the fitted regression plane. Create this plot.

**What's next:**

- Explore all our (>1000) R exercises
- Find an R course using our R Course Finder directory
- Subscribe to receive weekly updates and bonus sets by email
- Share with your friends and colleagues using the buttons below

## Leave a Reply