Parallel Slopes Model

Take a look at the parallel slopes model in multiple regression.

When creating regression models with one numerical and one categorical explanatory variable, we aren’t limited to interaction models, as we just saw. Another type of model we can use is known as a parallel slopes model. Unlike interaction models where the regression lines can have different intercepts and different slopes, parallel slopes models still allow for different intercepts but force all lines to have the same slope. The resulting regression lines are therefore parallel. Let’s visualize the best-fitting parallel slopes model to evals_ch6.

Unfortunately, the geom_smooth() function in the ggplot2 package doesn’t have a convenient way to plot parallel slopes models. Evgeni Chasnovski, therefore, created a special purpose function called geom_parallel_slopes() that’s included in the moderndive package. We won’t find geom_parallel_slopes() in the ggplot2 package, but rather the moderndive package. Thus, if we want to use it, we’ll need to load both the ggplot2 and moderndive packages. Using this function, let’s now plot the parallel slopes model for teaching scores. Notice how the code is identical to the code that produced the visualization of the interaction model, but now the geom_smooth(method = "lm", se = FALSE) layer is replaced with geom_parallel_slopes(se = FALSE).

Get hands-on with 1200+ tech skills courses.