Predicting with a parallel slopes model
While ggplot can automatically show you model predictions, in order to get those values to program with, you'll need to do the calculations yourself.
Just as with the case of a single explanatory variable, the workflow has two steps: create a data frame of explanatory variables, then add a column of predictions. To make sure you've got the right answer, you can add your predictions to the ggplot with the geom_parallel_slopes()
lines.
taiwan_real_estate
and mdl_price_vs_both
are available; dplyr
, tidyr
, and ggplot2
are loaded.
Cet exercice fait partie du cours
Intermediate Regression in R
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Make a grid of explanatory data
explanatory_data <- ___(
# Set n_convenience to zero to ten
___,
# Set house_age_years to the unique values of that variable
___
)
# See the result
explanatory_data