﻿figure it out - a statistical consultancy from the Institute of Work Psychology, University of Sheffield

## Mplus code for mediation, moderation, and moderated mediation models

Model 54: 1 or more mediators, in parallel if multiple (example uses 1), 4 moderators, 2 of which moderate the IV-Mediator path, with the other 2 moderating both the Mediator-DV path and the direct IV-DV path with all 2-way and 3-way interactions

Example Variables: 1 predictor X, 1 mediator M, 4 moderators W, Z, V, Q, 1 outcome Y

Preliminary notes:

The code below assumes that

• The primary IV (variable X) is continuous or dichotomous.
• Any moderators (variables W, V, Q, Z) are continuous, though the only adaptation required to handle dichotomous moderators is in the MODEL CONSTRAINT: and loop plot code - an example of how to do this is given in model 1b. Handling categorical moderators with > 2 categories is demonstrated in model 1d.
• Any mediators (variable M, or M1, M2, etc.) are continuous and satisfy the assumptions of standard multiple regression. An example of how to handle a dichotomous mediator is given in model 4c.
• The DV (variable Y) is continuous and satisfies the assumptions of standard multiple regression - an example of how to handle a dichotomous DV is given in model 1e (i.e. a moderated logistic regression) and in model 4d (i.e. an indirect effect in a logistic regression).

Model Diagram:

Statistical Diagram:

Model Equation(s):

Y = b0 + b1M + b2MV + b3MQ + b4MVQ + c1'X + c2'V + c3'Q + c4'XV + c5'XQ + c6'VQ + c7'XVQ
M = a0 + a1X + a2W + a3Z + a4XW + a5XZ

Algebra to calculate indirect and/or conditional effects by writing model as Y = a + bX:

Y = b0 + b1M + b2MV + b3MQ + b4MVQ + c1'X + c2'V + c3'Q + c4'XV + c5'XQ + c6'VQ + c7'XVQ
M = a0 + a1X + a2W + a3Z + a4XW + a5XZ

Hence... substituting in equation for M

Y = b0 + b1(a0 + a1X + a2W + a3Z + a4XW + a5XZ) + b2(a0 + a1X + a2W + a3Z + a4XW + a5XZ)V + b3(a0 + a1X + a2W + a3Z + a4XW + a5XZ)Q + b4(a0 + a1X + a2W + a3Z + a4XW + a5XZ)VQ + c1'X + c2'V + c3'Q + c4'XV + c5'XQ + c6'VQ + c7'XVQ

Hence... multiplying out brackets

Y = b0 + a0b1 + a1b1X + a2b1W + a3b1Z + a4b1XW + a5b1XZ + a0b2V + a1b2XV + a2b2WV + a3b2ZV + a4b2XWV + a5b2XZV + a0b3Q + a1b3XQ + a2b3WQ + a3b3ZQ + a4b3XWQ + a5b3XZQ + a0b4VQ + a1b4XVQ + a2b4WVQ + a3b4ZVQ + a4b4XWVQ + a5b4XZVQ + c1'X + c2'V + c3'Q + c4'XV + c5'XQ + c6'VQ + c7'XVQ

Hence... grouping terms into form Y = a + bX

Y = (b0 + a0b1 + a2b1W + a3b1Z + a0b2V + a2b2WV + a3b2ZV + a0b3Q + a2b3WQ + a3b3ZQ + a0b4VQ + a2b4WVQ + a3b4ZVQ + c2'V + c3'Q + c6'VQ) + (a1b1 + a4b1W + a5b1Z + a1b2V + a4b2WV + a5b2ZV + a1b3Q + a4b3WQ + a5b3ZQ + a1b4VQ + a4b4WVQ + a5b4ZVQ + c1' + c4'V + c5'Q + c7'VQ)X

Hence...

One indirect effect(s) of X on Y, conditional on W, Z, V, Q:

a1b1 + a4b1W + a5b1Z + a1b2V + a4b2WV + a5b2ZV + a1b3Q + a4b3WQ + a5b3ZQ + a1b4VQ + a4b4WVQ + a5b4ZVQ = (a1 + a4W + a5Z) (b1 + b2V + b3Q + b4VQ)

One direct effect of X on Y, conditional on V, Q:

c1' + c4'V + c5'Q + c7'VQ

Mplus code for the model:

! Predictor variable - X
! Mediator variable(s) – M
! Moderator variable(s) – W, Z, V, Q
! Outcome variable - Y

USEVARIABLES = X M W Z V Q Y XW XZ XV XQ VQ MV MQ XVQ MVQ;

! Create interaction terms
! Note that they have to be placed at end of USEVARIABLES subcommand above

DEFINE:
MQ = M*Q;
MV = M*V;
XW = X*W;
XZ = X*Z;
XQ = X*Q;
XV = X*V;
VQ = V*Q;
MVQ = M*V*Q;
XVQ = X*V*Q;

ANALYSIS:
TYPE = GENERAL;
ESTIMATOR = ML;
BOOTSTRAP = 10000;

! In model statement name each path and intercept using parentheses

MODEL:
[Y] (b0);
Y ON M (b1);
Y ON MV (b2);
Y ON MQ (b3);
Y ON MVQ (b4);

Y ON X (cdash1);
Y ON V (cdash2);
Y ON Q (cdash3);
Y ON XV (cdash4);
Y ON XQ (cdash5);
Y ON VQ (cdash6);
Y ON XVQ (cdash7);

[M] (a0);
M ON X (a1);
M ON W (a2);
M ON Z (a3);
M ON XW (a4);
M ON XZ (a5);

! Use model constraint subcommand to test conditional indirect effects
! You need to pick low, medium and high moderator values for W, Z, V, Q
! for example, of 1 SD below mean, mean, 1 SD above mean

! 4 moderators, 3 values for each, gives 81 combinations
! arbitrary naming convention for conditional indirect and total effects used below:
! HHML = high value of W, high value of Z, medium value of V and low value of Q.

MODEL CONSTRAINT:
NEW(LOW_W MED_W HIGH_W LOW_Z MED_Z HIGH_Z LOW_V MED_V HIGH_V LOW_Q MED_Q HIGH_Q
ILLLL IMLLL IHLLL ILMLL IMMLL IHMLL ILHLL IMHLL IHHLL
ILLML IMLML IHLML ILMML IMMML IHMML ILHML IMHML IHHML
ILLHL IMLHL IHLHL ILMHL IMMHL IHMHL ILHHL IMHHL IHHHL
ILLLM IMLLM IHLLM ILMLM IMMLM IHMLM ILHLM IMHLM IHHLM
ILLMM IMLMM IHLMM ILMMM IMMMM IHMMM ILHMM IMHMM IHHMM
ILLHM IMLHM IHLHM ILMHM IMMHM IHMHM ILHHM IMHHM IHHHM
ILLLH IMLLH IHLLH ILMLH IMMLH IHMLH ILHLH IMHLH IHHLH
ILLMH IMLMH IHLMH ILMMH IMMMH IHMMH ILHMH IMHMH IHHMH
ILLHH IMLHH IHLHH ILMHH IMMHH IHMHH ILHHH IMHHH IHHHH
DLOV_LOQ DMEV_LOQ DHIV_LOQ DLOV_MEQ DMEV_MEQ DHIV_MEQ
DLOV_HIQ DMEV_HIQ DHIV_HIQ
TLLLL TMLLL THLLL TLMLL TMMLL THMLL TLHLL TMHLL THHLL
TLLML TMLML THLML TLMML TMMML THMML TLHML TMHML THHML
TLLHL TMLHL THLHL TLMHL TMMHL THMHL TLHHL TMHHL THHHL
TLLLM TMLLM THLLM TLMLM TMMLM THMLM TLHLM TMHLM THHLM
TLLMM TMLMM THLMM TLMMM TMMMM THMMM TLHMM TMHMM THHMM
TLLHM TMLHM THLHM TLMHM TMMHM THMHM TLHHM TMHHM THHHM
TLLLH TMLLH THLLH TLMLH TMMLH THMLH TLHLH TMHLH THHLH
TLLMH TMLMH THLMH TLMMH TMMMH THMMH TLHMH TMHMH THHMH
TLLHH TMLHH THLHH TLMHH TMMHH THMHH TLHHH TMHHH THHHH);

LOW_W = #LOWW;   ! replace #LOWW in the code with your chosen low value of W
MED_W = #MEDW;   ! replace #MEDW in the code with your chosen medium value of W
HIGH_W = #HIGHW;   ! replace #HIGHW in the code with your chosen high value of W

LOW_Z = #LOWZ;   ! replace #LOWZ in the code with your chosen low value of Z
MED_Z = #MEDZ;   ! replace #MEDZ in the code with your chosen medium value of Z
HIGH_Z = #HIGHZ;   ! replace #HIGHZ in the code with your chosen high value of Z

LOW_V = #LOWV;   ! replace #LOWV in the code with your chosen low value of V
MED_V = #MEDV;   ! replace #MEDV in the code with your chosen medium value of V
HIGH_V = #HIGHV;   ! replace #HIGHV in the code with your chosen high value of V

LOW_Q = #LOWQ;   ! replace #LOWQ in the code with your chosen low value of Q
MED_Q = #MEDQ;   ! replace #MEDQ in the code with your chosen medium value of Q
HIGH_Q = #HIGHQ;   ! replace #HIGHQ in the code with your chosen high value of Q

! Calc conditional indirect effects for each combination of moderator values

ILLLL = a1*b1 + a4*b1*LOW_W + a5*b1*LOW_Z + a1*b2*LOW_V +
a4*b2*LOW_W*LOW_V + a5*b2*LOW_Z*LOW_V + a1*b3*LOW_Q +
a4*b3*LOW_W*LOW_Q + a5*b3*LOW_Z*LOW_Q + a1*b4*LOW_V*LOW_Q +
a4*b4*LOW_W*LOW_V*LOW_Q + a5*b4*LOW_Z*LOW_V*LOW_Q;
IMLLL = a1*b1 + a4*b1*MED_W + a5*b1*LOW_Z + a1*b2*LOW_V +
a4*b2*MED_W*LOW_V + a5*b2*LOW_Z*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1*HIGH_W + a5*b1*LOW_Z + a1*b2*MED_V +
a4*b2*HIGH_W*MED_V + a5*b2*LOW_Z*MED_V + a1*b3*LOW_Q +
a4*b3*HIGH_W*LOW_Q + a5*b3*LOW_Z*LOW_Q + a1*b4*MED_V*LOW_Q +
a4*b4*HIGH_W*MED_V*LOW_Q + a5*b4*LOW_Z*MED_V*LOW_Q;

ILMML = a1*b1 + a4*b1*LOW_W + a5*b1*MED_Z + a1*b2*MED_V +
a4*b2*LOW_W*MED_V + a5*b2*MED_Z*MED_V + a1*b3*LOW_Q +
a4*b3*LOW_W*LOW_Q + a5*b3*MED_Z*LOW_Q + a1*b4*MED_V*LOW_Q +
a4*b4*LOW_W*MED_V*LOW_Q + a5*b4*MED_Z*MED_V*LOW_Q;
IMMML = a1*b1 + a4*b1*MED_W + a5*b1*MED_Z + a1*b2*MED_V +
a4*b2*MED_W*MED_V + a5*b2*MED_Z*MED_V + a1*b3*LOW_Q +
a4*b3*MED_W*LOW_Q + a5*b3*MED_Z*LOW_Q + a1*b4*MED_V*LOW_Q +
a4*b4*MED_W*MED_V*LOW_Q + a5*b4*MED_Z*MED_V*LOW_Q;
IHMML = a1*b1 + a4*b1*HIGH_W + a5*b1*MED_Z + a1*b2*MED_V +
a4*b2*HIGH_W*MED_V + a5*b2*MED_Z*MED_V + a1*b3*LOW_Q +
a4*b3*HIGH_W*LOW_Q + a5*b3*MED_Z*LOW_Q + a1*b4*MED_V*LOW_Q +
a4*b4*HIGH_W*MED_V*LOW_Q + a5*b4*MED_Z*MED_V*LOW_Q;

ILHML = a1*b1 + a4*b1*LOW_W + a5*b1*HIGH_Z + a1*b2*MED_V +
a4*b2*LOW_W*MED_V + a5*b2*HIGH_Z*MED_V + a1*b3*LOW_Q +
a4*b3*LOW_W*LOW_Q + a5*b3*HIGH_Z*LOW_Q + a1*b4*MED_V*LOW_Q +
a4*b4*LOW_W*MED_V*LOW_Q + a5*b4*HIGH_Z*MED_V*LOW_Q;
IMHML = a1*b1 + a4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+ a5*b2*HIGH_Z*LOW_V + a1*b3*MED_Q +
a4*b3*HIGH_W*MED_Q + a5*b3*HIGH_Z*MED_Q + a1*b4*LOW_V*MED_Q +
a4*b4*HIGH_W*LOW_V*MED_Q + a5*b4*HIGH_Z*LOW_V*MED_Q;

ILLMM = a1*b1 + a4*b1*LOW_W + a5*b1*LOW_Z + a1*b2*MED_V +
a4*b2*LOW_W*MED_V + a5*b2*LOW_Z*MED_V + a1*b3*MED_Q +
a4*b3*LOW_W*MED_Q + a5*b3*LOW_Z*MED_Q + a1*b4*MED_V*MED_Q +
a4*b4*LOW_W*MED_V*MED_Q + a5*b4*LOW_Z*MED_V*MED_Q;
IMLMM = a1*b1 + a4*b1*MED_W + a5*b1*LOW_Z + a1*b2*MED_V +
a4*b2*MED_W*MED_V + a5*b2*LOW_Z*MED_V + a1*b3*MED_Q +
a4*b3*MED_W*MED_Q + a5*b3*LOW_Z*MED_Q + a1*b4*MED_V*MED_Q +
a4*b4*MED_W*MED_V*MED_Q + a5*b4*LOW_Z*MED_V*MED_Q;
IHLMM = a1*b1 + a4*b1*HIGH_W + a5*b1*LOW_Z + a1*b2*MED_V +
a4*b2*HIGH_W*MED_V + a5*b2*LOW_Z*MED_V + a1*b3*MED_Q +
a4*b3*HIGH_W*MED_Q + a5*b3*LOW_Z*MED_Q + a1*b4*MED_V*MED_Q +
a4*b4*HIGH_W*MED_V*MED_Q + a5*b4*LOW_Z*MED_V*MED_Q;

ILMMM = a1*b1 + a4*b1*LOW_W + a5*b1*MED_Z + a1*b2*MED_V +
a4*b2*LOW_W*MED_V + a5*b2*MED_Z*MED_V + a1*b3*MED_Q +
a4*b3*LOW_W*MED_Q + a5*b3*MED_Z*MED_Q + a1*b4*MED_V*MED_Q +
a4*b4*LOW_W*MED_V*MED_Q + a5*b4*MED_Z*MED_V*MED_Q;
IMMMM = a1*b1 + a4*b1*MED_W + a5*b1*MED_Z + a1*b2*MED_V +
a4*b2*MED_W*MED_V + a5*b2*MED_Z*MED_V + a1*b3*MED_Q +
a4*b3*MED_W*MED_Q + a5*b3*MED_Z*MED_Q + a1*b4*MED_V*MED_Q +
a4*b4*MED_W*MED_V*MED_Q + a5*b4*MED_Z*MED_V*MED_Q;
IHMMM = a1*b1 + a4*b1*HIGH_W + a5*b1*MED_Z + a1*b2*MED_V +
a4*b2*HIGH_W*MED_V + a5*b2*MED_Z*MED_V + a1*b3*MED_Q +
a4*b3*HIGH_W*MED_Q + a5*b3*MED_Z*MED_Q + a1*b4*MED_V*MED_Q +
a4*b4*HIGH_W*MED_V*MED_Q + a5*b4*MED_Z*MED_V*MED_Q;

ILHMM = a1*b1 + a4*b1*LOW_W + a5*b1*HIGH_Z + a1*b2*MED_V +
a4*b2*LOW_W*MED_V + a5*b2*HIGH_Z*MED_V + a1*b3*MED_Q +
a4*b3*LOW_W*MED_Q + a5*b3*HIGH_Z*MED_Q + a1*b4*MED_V*MED_Q +
a4*b4*LOW_W*MED_V*MED_Q + a5*b4*HIGH_Z*MED_V*MED_Q;
IMHMM = a1*b1 + a4*b1*MED_W + a5*b1*HIGH_Z + a1*b2*MED_V +
a4*b2*MED_W*MED_V + a5*b2*HIGH_Z*MED_V + a1*b3*MED_Q +
a4*b3*MED_W*MED_Q + a5*b3*HIGH_Z*MED_Q + a1*b4*MED_V*MED_Q +
a4*b4*MED_W*MED_V*MED_Q + a5*b4*HIGH_Z*MED_V*MED_Q;
IHHMM = a1*b1 + a4*b1*HIGH_W + a5*b1*HIGH_Z + a1*b2*MED_V +
a4*b2*HIGH_W*MED_V + a5*b2*HIGH_Z*MED_V + a1*b3*MED_Q +
a4*b3*HIGH_W*MED_Q + a5*b3*HIGH_Z*MED_Q + a1*b4*MED_V*MED_Q +
a4*b4*HIGH_W*MED_V*MED_Q + a5*b4*HIGH_Z*MED_V*MED_Q;

ILLHM = a1*b1 + a4*b1*LOW_W + a5*b1*LOW_Z + a1*b2*HIGH_V +
a4*b2*LOW_W*HIGH_V + a5*b2*LOW_Z*HIGH_V + a1*b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HIGH_Q + a5*b3*HIGH_Z*HIGH_Q + a1*b4*HIGH_V*HIGH_Q +
a4*b4*LOW_W*HIGH_V*HIGH_Q + a5*b4*HIGH_Z*HIGH_V*HIGH_Q;
IMHHH = a1*b1 + a4*b1*MED_W + a5*b1*HIGH_Z + a1*b2*HIGH_V +
a4*b2*MED_W*HIGH_V + a5*b2*HIGH_Z*HIGH_V + a1*b3*HIGH_Q +
a4*b3*MED_W*HIGH_Q + a5*b3*HIGH_Z*HIGH_Q + a1*b4*HIGH_V*HIGH_Q +
a4*b4*MED_W*HIGH_V*HIGH_Q + a5*b4*HIGH_Z*HIGH_V*HIGH_Q;
IHHHH = a1*b1 + a4*b1*HIGH_W + a5*b1*HIGH_Z + a1*b2*HIGH_V +
a4*b2*HIGH_W*HIGH_V + a5*b2*HIGH_Z*HIGH_V + a1*b3*HIGH_Q +
a4*b3*HIGH_W*HIGH_Q + a5*b3*HIGH_Z*HIGH_Q + a1*b4*HIGH_V*HIGH_Q +
a4*b4*HIGH_W*HIGH_V*HIGH_Q + a5*b4*HIGH_Z*HIGH_V*HIGH_Q;

! Calc conditional direct effects for each combination of moderator values

DLOV_LOQ = cdash1 + cdash4*LOW_V + cdash5*LOW_Q + cdash7*LOW_V*LOW_Q;
DMEV_LOQ = cdash1 + cdash4*MED_V + cdash5*LOW_Q + cdash7*MED_V*LOW_Q;
DHIV_LOQ = cdash1 + cdash4*HIGH_V + cdash5*LOW_Q + cdash7*HIGH_V*LOW_Q;

DLOV_MEQ = cdash1 + cdash4*LOW_V + cdash5*MED_Q + cdash7*LOW_V*MED_Q;
DMEV_MEQ = cdash1 + cdash4*MED_V + cdash5*MED_Q + cdash7*MED_V*MED_Q;
DHIV_MEQ = cdash1 + cdash4*HIGH_V + cdash5*MED_Q + cdash7*HIGH_V*MED_Q;

DLOV_HIQ = cdash1 + cdash4*LOW_V + cdash5*HIGH_Q + cdash7*LOW_V*HIGH_Q;
DMEV_HIQ = cdash1 + cdash4*MED_V + cdash5*HIGH_Q + cdash7*MED_V*HIGH_Q;
DHIV_HIQ = cdash1 + cdash4*HIGH_V + cdash5*HIGH_Q + cdash7*HIGH_V*HIGH_Q;

! Calc conditional total effects for each combination of moderator values

TLLLL = ILLLL + DLOV_LOQ;
TMLLL = IMLLL + DLOV_LOQ;
THLLL = IHLLL + DLOV_LOQ;

TLMLL = ILMLL + DLOV_LOQ;
TMMLL = IMMLL + DLOV_LOQ;
THMLL = IHMLL + DLOV_LOQ;

TLHLL = ILHLL + DLOV_LOQ;
TMHLL = IMHLL + DLOV_LOQ;
THHLL = IHHLL + DLOV_LOQ;

TLLML = ILLML + DMEV_LOQ;
TMLML = IMLML + DMEV_LOQ;
THLML = IHLML + DMEV_LOQ;

TLMML = ILMML + DMEV_LOQ;
TMMML = IMMML + DMEV_LOQ;
THMML = IHMML + DMEV_LOQ;

TLHML = ILHML + DMEV_LOQ;
TMHML = IMHML + DMEV_LOQ;
THHML = IHHML + DMEV_LOQ;

TLLHL = ILLHL + DHIV_LOQ;
TMLHL = IMLHL + DHIV_LOQ;
THLHL = IHLHL + DHIV_LOQ;

TLMHL = ILMHL + DHIV_LOQ;
TMMHL = IMMHL + DHIV_LOQ;
THMHL = IHMHL + DHIV_LOQ;

TLHHL = ILHHL + DHIV_LOQ;
TMHHL = IMHHL + DHIV_LOQ;
THHHL = IHHHL + DHIV_LOQ;

TLLLM = ILLLM + DLOV_MEQ;
TMLLM = IMLLM + DLOV_MEQ;
THLLM = IHLLM + DLOV_MEQ;

TLMLM = ILMLM + DLOV_MEQ;
TMMLM = IMMLM + DLOV_MEQ;
THMLM = IHMLM + DLOV_MEQ;

TLHLM = ILHLM + DLOV_MEQ;
TMHLM = IMHLM + DLOV_MEQ;
THHLM = IHHLM + DLOV_MEQ;

TLLMM = ILLMM + DMEV_MEQ;
TMLMM = IMLMM + DMEV_MEQ;
THLMM = IHLMM + DMEV_MEQ;

TLMMM = ILMMM + DMEV_MEQ;
TMMMM = IMMMM + DMEV_MEQ;
THMMM = IHMMM + DMEV_MEQ;

TLHMM = ILHMM + DMEV_MEQ;
TMHMM = IMHMM + DMEV_MEQ;
THHMM = IHHMM + DMEV_MEQ;

TLLHM = ILLHM + DHIV_MEQ;
TMLHM = IMLHM + DHIV_MEQ;
THLHM = IHLHM + DHIV_MEQ;

TLMHM = ILMHM + DHIV_MEQ;
TMMHM = IMMHM + DHIV_MEQ;
THMHM = IHMHM + DHIV_MEQ;

TLHHM = ILHHM + DHIV_MEQ;
TMHHM = IMHHM + DHIV_MEQ;
THHHM = IHHHM + DHIV_MEQ;

TLLLH = ILLLH + DLOV_HIQ;
TMLLH = IMLLH + DLOV_HIQ;
THLLH = IHLLH + DLOV_HIQ;

TLMLH = ILMLH + DLOV_HIQ;
TMMLH = IMMLH + DLOV_HIQ;
THMLH = IHMLH + DLOV_HIQ;

TLHLH = ILHLH + DLOV_HIQ;
TMHLH = IMHLH + DLOV_HIQ;
THHLH = IHHLH + DLOV_HIQ;

TLLMH = ILLMH + DMEV_HIQ;
TMLMH = IMLMH + DMEV_HIQ;
THLMH = IHLMH + DMEV_HIQ;

TLMMH = ILMMH + DMEV_HIQ;
TMMMH = IMMMH + DMEV_HIQ;
THMMH = IHMMH + DMEV_HIQ;

TLHMH = ILHMH + DMEV_HIQ;
TMHMH = IMHMH + DMEV_HIQ;
THHMH = IHHMH + DMEV_HIQ;

TLLHH = ILLHH + DHIV_HIQ;
TMLHH = IMLHH + DHIV_HIQ;
THLHH = IHLHH + DHIV_HIQ;

TLMHH = ILMHH + DHIV_HIQ;
TMMHH = IMMHH + DHIV_HIQ;
THMHH = IHMHH + DHIV_HIQ;

TLHHH = ILHHH + DHIV_HIQ;
TMHHH = IMHHH + DHIV_HIQ;
THHHH = IHHHH + DHIV_HIQ;

! Use loop plot to plot conditional indirect effect of X on Y for each combination of low, med, high moderator values
! Could be edited to show conditional direct or conditional total effects instead
! NOTE - values of 1,5 in LOOP() statement need to be replaced by
! logical min and max limits of predictor X used in analysis

PLOT(PLLLL PMLLL PHLLL PLMLL PMMLL PHMLL PLHLL PMHLL PHHLL
PLLML PMLML PHLML PLMML PMMML PHMML PLHML PMHML PHHML
PLLHL PMLHL PHLHL PLMHL PMMHL PHMHL PLHHL PMHHL PHHHL
PLLLM PMLLM PHLLM PLMLM PMMLM PHMLM PLHLM PMHLM PHHLM
PLLMM PMLMM PHLMM PLMMM PMMMM PHMMM PLHMM PMHMM PHHMM
PLLHM PMLHM PHLHM PLMHM PMMHM PHMHM PLHHM PMHHM PHHHM
PLLLH PMLLH PHLLH PLMLH PMMLH PHMLH PLHLH PMHLH PHHLH
PLLMH PMLMH PHLMH PLMMH PMMMH PHMMH PLHMH PMHMH PHHMH
PLLHH PMLHH PHLHH PLMHH PMMHH PHMHH PLHHH PMHHH PHHHH);

LOOP(XVAL,1,5,0.1);

PLLLL = ILLLL*XVAL;
PMLLL = IMLLL*XVAL;
PHLLL = IHLLL*XVAL;

PLMLL = ILMLL*XVAL;
PMMLL = IMMLL*XVAL;
PHMLL = IHMLL*XVAL;

PLHLL = ILHLL*XVAL;
PMHLL = IMHLL*XVAL;
PHHLL = IHHLL*XVAL;

PLLML = ILLML*XVAL;
PMLML = IMLML*XVAL;
PHLML = IHLML*XVAL;

PLMML = ILMML*XVAL;
PMMML = IMMML*XVAL;
PHMML = IHMML*XVAL;

PLHML = ILHML*XVAL;
PMHML = IMHML*XVAL;
PHHML = IHHML*XVAL;

PLLHL = ILLHL*XVAL;
PMLHL = IMLHL*XVAL;
PHLHL = IHLHL*XVAL;

PLMHL = ILMHL*XVAL;
PMMHL = IMMHL*XVAL;
PHMHL = IHMHL*XVAL;

PLHHL = ILHHL*XVAL;
PMHHL = IMHHL*XVAL;
PHHHL = IHHHL*XVAL;

PLLLM = ILLLM*XVAL;
PMLLM = IMLLM*XVAL;
PHLLM = IHLLM*XVAL;

PLMLM = ILMLM*XVAL;
PMMLM = IMMLM*XVAL;
PHMLM = IHMLM*XVAL;

PLHLM = ILHLM*XVAL;
PMHLM = IMHLM*XVAL;
PHHLM = IHHLM*XVAL;

PLLMM = ILLMM*XVAL;
PMLMM = IMLMM*XVAL;
PHLMM = IHLMM*XVAL;

PLMMM = ILMMM*XVAL;
PMMMM = IMMMM*XVAL;
PHMMM = IHMMM*XVAL;

PLHMM = ILHMM*XVAL;
PMHMM = IMHMM*XVAL;
PHHMM = IHHMM*XVAL;

PLLHM = ILLHM*XVAL;
PMLHM = IMLHM*XVAL;
PHLHM = IHLHM*XVAL;

PLMHM = ILMHM*XVAL;
PMMHM = IMMHM*XVAL;
PHMHM = IHMHM*XVAL;

PLHHM = ILHHM*XVAL;
PMHHM = IMHHM*XVAL;
PHHHM = IHHHM*XVAL;

PLLLH = ILLLH*XVAL;
PMLLH = IMLLH*XVAL;
PHLLH = IHLLH*XVAL;

PLMLH = ILMLH*XVAL;
PMMLH = IMMLH*XVAL;
PHMLH = IHMLH*XVAL;

PLHLH = ILHLH*XVAL;
PMHLH = IMHLH*XVAL;
PHHLH = IHHLH*XVAL;

PLLMH = ILLMH*XVAL;
PMLMH = IMLMH*XVAL;
PHLMH = IHLMH*XVAL;

PLMMH = ILMMH*XVAL;
PMMMH = IMMMH*XVAL;
PHMMH = IHMMH*XVAL;

PLHMH = ILHMH*XVAL;
PMHMH = IMHMH*XVAL;
PHHMH = IHHMH*XVAL;

PLLHH = ILLHH*XVAL;
PMLHH = IMLHH*XVAL;
PHLHH = IHLHH*XVAL;

PLMHH = ILMHH*XVAL;
PMMHH = IMMHH*XVAL;
PHMHH = IHMHH*XVAL;

PLHHH = ILHHH*XVAL;
PMHHH = IMHHH*XVAL;
PHHHH = IHHHH*XVAL;

PLOT:
TYPE = plot2;

OUTPUT:
STAND CINT(bcbootstrap);