Graphically evaluate the unemployment model
In this exercise, you will graphically evaluate the unemployment model, unemployment_model
, that you fit to
the unemployment
data in the previous chapter. Recall that the model predicts female_unemployment
from male_unemployment
.
You will plot the model's predictions against the actual female_unemployment
; recall the command is of the form
ggplot(dframe, aes(x = pred, y = outcome)) +
geom_point() +
geom_abline()
Then you will calculate the residuals:
residuals <- actual outcome - predicted outcome
and plot predictions against residuals. The residual graph will take a slightly different form: you compare the residuals to the horizontal line \(y=0\) (using geom_hline()
) rather than to the line \(x=y\). The command will be provided.
The data frame unemployment
and model unemployment_model
have been pre-loaded.
This exercise is part of the course
Supervised Learning in R: Regression
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# unemployment and unemployment_model are available
summary(unemployment)
summary(unemployment_model)
# Make predictions from the model
unemployment$predictions <- ___
# Fill in the blanks to plot predictions (on x-axis) versus the female_unemployment rates
___(___, aes(x = ___, y = ___)) +
geom_point() +
geom_abline()