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.
This exercise is part of the course
Intermediate Regression in R
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Using taiwan_real_estate, plot price vs. no. of conv. stores colored by house age
___ +
# Make it a scatter plot
___ +
# Add smooth linear regression trend lines, no ribbon
___