Exercise

Visualizing multiple models

In the last two exercises, you ran models for each category of house ages separately, then calculated predictions for each model. Now it's time to visualize those predictions to see how they compare.

When you use geom_smooth() in a ggplot with an aesthetic that splits the dataset into groups and draws a line for each group (like the color aesthetic), you get multiple trend lines. This is the same as running a model on each group separately, so we get a chance to test our predictions against ggplot's.

taiwan_real_estate, prediction_data_0_to_15, prediction_data_15_to_30, and prediction_data_30_to_45 are available; ggplot2 is loaded.

Instructions 1/2

undefined XP
    1
    2
  • Using taiwan_real_estate, plot price_twd_msq versus n_convenience colored by house_age_years.
  • Add a point layer.
  • Add smooth trend lines for each color using the linear regression method and turning off the standard error ribbon.