Exercise

Assumptions I

Before we can use regression analyses we need to make sure that our data fits all necessary assumptions.

The assumption of linearity says that the predictors should be linearly related to the response variable. As we cannot really do this when we have more than one predictor, we are going to look at the residuals against the response variable. We would hope to see the residuals move in a straight line.

While we are looking at these residuals, we can also check out the assumption of homoscedasticity. To check this we should make sure the variation in residuals is roughly even at all levels of the predictor.

We can get the residuals from the summary() of our model, using $residuals. For example: summary(model)$residuals. We can then plot the residuals against the predictors using plot(), which takes the x-axis data as the first argument, and the y-axis data as the second argument.

Instructions

100 XP
  • In your script, index the residuals from your model using $, and assign them to the object resmod
  • In your script, plot resmod alongside smile and money using the function plot().
  • The first argument of plot() is the data that goes on the x-axis, and the second is the data on the y-axis. For example: plot(x_data, y_data).