Chapter 8 Moderation and Stratification

Sometimes the relationship between X and Y may change depending on the value of a third variable. This section provides some motivation for why we need a single model formation that can accommodate more than a single predictor.

This section uses functions from the ggdist and ggpubr packages to help tidy and visualize results from regression models. It also uses functions from the performance and glmnet packages to perform model selection and assessment.

This section uses the additional following packages and data:

library(ggdist) # for the "half-violin" plot (stat_slab)
library(ggpubr) # for the penguin scatterplot with ellipses (ggscatter)
pen <- palmerpenguins::penguins