Mplus code for the mediation, moderation, and moderated mediation model templates from Andrew Hayes' PROCESS analysis examplesModel 4: 1 or more mediators (2 in this example), in parallel if multiple [BASIC MEDIATION] Example Variables: 1 predictor X, 2 mediators M1 and M2, 1 outcome Y Preliminary notes: The code below assumes that
Model Diagram:
Statistical Diagram:
Model Equation(s): Y = b0 + b1M1 + b2M2 + c'X
Albegra to calculate total, indirect and/or conditional effects by writing model as Y = a + bX: Y = b0 + b1M1 + b2M2 + c'X
Y = b0 + b1(a01 + a1X) + b2(a02 + a2X) + c'X
Y = b0 + a01b1 + a1b1X + a02b2 + a2b2X + c'X
Y = (b0 + a01b1 + a02b2) + (a1b1 + a2b2 + c')X
Two indirect effects of X on Y: a1b1, a2b2 One direct effect of X on Y: c'
Mplus code for the model:
! Predictor variable  X
USEVARIABLES = X M1 M2 Y; ANALYSIS:
! In model statement name each path using parentheses MODEL:
Y ON X (cdash); ! direct effect of X on Y M1 ON X (a1);
! Use model constraint to calculate specific indirect paths and total indirect effect MODEL CONSTRAINT:
OUTPUT:
Editing required for testing indirect effect(s) using alternative MODEL INDIRECT: subcommand MODEL INDIRECT: offers an alternative to MODEL CONSTRAINT: for models containing indirect effects, where these are not moderated. To use MODEL INDIRECT: instead, you would edit the code above as follows: First, you can remove the naming of parameters using parentheses in the MODEL: command, i.e. you just need: MODEL:
Second, replace the MODEL CONSTRAINT: subcommand with the following MODEL INDIRECT: subcommand: MODEL INDIRECT:
Leave the OUTPUT: command unchanged.
Editing required for dichotomous DV scenario (logistic regression with an indirect effect) Coming soon...
Return to Model Template index. To cite this page and/or any code used, please use:







