1. Learn
  2. /
  3. Courses
  4. /
  5. Supervised Learning in R: Regression

Exercise

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.

Instructions 1/2

undefined XP
    1
    2
  • Use predict() to get the model predictions and add them to unemployment as the column predictions.
  • Plot predictions (on the x-axis) versus actual female unemployment rates. Are the predictions near the \(x=y\) line?