Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Intermediate Regression in R

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# 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
Code bewerken en uitvoeren