Session Ready
Exercise

Tiling the plane

One method for visualizing a multiple linear regression model is to create a heatmap of the fitted values in the plane defined by the two explanatory variables. This heatmap will illustrate how the model output changes over different combinations of the explanatory variables.

This is a multistep process:

  • First, create a grid of the possible pairs of values of the explanatory variables. The grid should be over the actual range of the data present in each variable. We've done this for you and stored the result as a data frame called grid.
  • Use augment() with the newdata argument to find the \(\hat{y}\)'s corresponding to the values in grid.
  • Add these to the data_space plot by using the fill aesthetic and geom_tile().
Instructions
100 XP

The model object mod is already in your workspace.

  • Use augment() to create a data.frame that contains the values the model outputs for each row of grid.
  • Use geom_tile to illustrate these predicted values over the data_space plot. Use the fill aesthetic and set alpha = 0.5.