Mplus code for the mediation, moderation, and moderated mediation model templates from Andrew Hayes' PROCESS analysis examplesModel 1c: 1 moderator [BASIC MODERATION], dichotomous moderator (using multigroup method) 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
so inserting the values of 0 and 1 for moderator W gives....
 
Mplus code for the model:
! Predictor variable - X
USEVARIABLES = X W Y XW;
! Define groups of moderator W
GROUPING = W (0 = GP0 1 = GP1);
ANALYSIS:
! In model statement first state basic regression that is being moderated
MODEL:
! Then restate for each group, naming each group's intercept and slope coefficient
  MODEL GP0:
  MODEL GP1:
! Use model constraint subcommand to create and test difference in slopes
MODEL CONSTRAINT:
   b3 = b1g1 - b1g0;
! Use loop plot to plot model for values of W = 0, W = 1
   PLOT(LINEGP0 LINEGP1);
   LINEGP0 = b0g0 + b1g0*XVAL;
PLOT:
OUTPUT:
 
Return to Model Template index.
To cite this page and/or any code used, please use:
|
|
|
|
|
|
|
|