Mplus code for the mediation, moderation, and moderated mediation model templates from Andrew Hayes' PROCESS analysis examplesModel 1a: 1 moderator [BASIC MODERATION], continuous moderator example Example Variables: 1 predictor X, 1 moderator W, 1 outcome Y Preliminary notes: The code below assumes that
  Model Diagram: ![]()   Statistical Diagram: ![]()   Model Equation(s):
Y = b0 + b1X + b2W + b3XW
 
Algebra to calculate indirect and/or conditional effects by writing model as Y = a + bX:
Y = b0 + b1X + b2W + b3XW
Y = (b0 + b2W) + (b1 + b3W)X
One direct effect of X on Y, conditional on W:
b1 + b3W
 
Mplus code for the model:
! Predictor variable - X
USEVARIABLES = X W Y XW;
! Create interaction term
DEFINE:
ANALYSIS:
! In model statement name each path and intercept using parentheses
MODEL:
! Use model constraint subcommand to test simple slopes
MODEL CONSTRAINT:
   LOW_W = #LOWW;   ! replace #LOWW in the code with your chosen low value of W
! Now calc simple slopes for each value of W
   SIMP_LO = b1 + b3*LOW_W;
! Use loop plot to plot model for low, med, high values of W
   PLOT(LOMOD MEDMOD HIMOD);
PLOT:
OUTPUT:
 
Return to Model Template index.
To cite this page and/or any code used, please use:
|
|
|
|
|
|
|
|