Moderation describes the relationship between two variables which is conditional on a third variable. Orthogonalizing a predictor can simplify modeling with moderations, by removing covariation with other predictors. With the lavaan package in R, you can create a moderation model with orthogonalized predictors by following these steps:
Load the lavaan package and your data:
main.r49 chars3 lines
Center and standardize your predictors:
main.r164 chars3 lines
Create a model with the orthogonalized predictor as a mediator of the relationship between the original predictor and the outcome:
main.r206 chars5 lines
Fit the model using the lavaan sem()
function:
main.r39 chars2 lines
Inspect the results using the summary()
function:
main.r19 chars2 lines
By orthogonalizing one predictor, you can model conditional effects of that predictor while removing covariation with other predictors. This can lead to a more parsimonious and interpretable model.
gistlibby LogSnag