Testing Assumptions II
One of the assumptions for running a regression analysis is that the relationship between the predictor and response variable is linear. It was a little hard to tell if this was definitely the case from plotting money against liking in the last exercise. Let's use those residuals you stored as resmod1
and plot these against liking to see if we can get a better idea of linearity.
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 and response variables.
To do this we're going to use the plot()
function. The first argument that plot takes is the x axis variable, and the second is the y-axis variable. After this plot()
can take many optional arguments, but you don't need to worry about these right now.
This exercise is part of the course
Inferential Statistics
Exercise instructions
- The variable
liking
and residualsresmod1
are saved in your console. - Plot the residuals on the y-axis against
liking
usingplot()
- Plot the residuals on the y-axis against
money
usingplot()
- Have a look at the outcome!
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# plot the residuals on the y-axis, and liking on the x-axis
# plot the residuals on the y-axis, and money on the x-axis