CommencerCommencer gratuitement

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.

Cet exercice fait partie du cours

Intermediate Regression in R

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de 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
  ___
Modifier et exécuter le code