Mplus code for mediation, moderation, and moderated mediation models

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

Example Variables: 1 latent predictor X measured by 4 observed variables X1-X4, 1 latent mediator M measured by 4 observed variables M1-M4, 4 latent moderators W, Z, V, and Q, each measured by sets of 4 observed variables W1-W4, Z1-Z4, V1-V4, and Q1-Q4 respectively, 1 latent outcome Y measured by 4 observed variables Y1-Y4

Preliminary notes:

The code below assumes that

  • The latent IV (factor X) is measured by continuous observed variables X1-X4.
  • Any latent moderator(s) (factors W, V, Q, Z) are measured by continuous observed variables W1-W4, Z1-Z4, V1-V4, Q1-Q4 respectively.
  • Any latent mediator(s) (factor M, or factors M1, M2, etc.) are measured by continuous observed variables M1-M4 or M1_1-M1-4, M2_1-M2_4 respectively.
  • The latent outcome Y is measured by continuous observed variables Y1-Y4.

 

Model Diagram (factor indicator variables omitted for space/clarity reasons):

 

Statistical Diagram (factor indicator variables omitted for space/clarity reasons):

 

Model Equation(s):

Y = b0 + b1M + b2V + b3Q + b4MV + b5MQ + b6VQ + b7MVQ + c1'X + c2'W + c3'Z + c4'XW + c5'XZ + c6'WZ + c7'XWZ
M = a0 + a1X + a2W + a3Z + a4XW + a5XZ + a6WZ + a7XWZ

 

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

Y = b0 + b1M + b2V + b3Q + b4MV + b5MQ + b6VQ + b7MVQ + c1'X + c2'W + c3'Z + c4'XW + c5'XZ + c6'WZ + c7'XWZ
M = a0 + a1X + a2W + a3Z + a4XW + a5XZ + a6WZ + a7XWZ


Hence... substituting in equation for M

Y = b0 + b1(a0 + a1X + a2W + a3Z + a4XW + a5XZ + a6WZ + a7XWZ) + b2V + b3Q + b4(a0 + a1X + a2W + a3Z + a4XW + a5XZ + a6WZ + a7XWZ)V + b5(a0 + a1X + a2W + a3Z + a4XW + a5XZ + a6WZ + a7XWZ)Q + b6VQ + b7(a0 + a1X + a2W + a3Z + a4XW + a5XZ + a6WZ + a7XWZ)VQ + c1'X + c2'W + c3'Z + c4'XW + c5'XZ + c6'WZ + c7'XWZ


Hence... multiplying out brackets

Y = b0 + a0b1 + a1b1X + a2b1W + a3b1Z + a4b1XW + a5b1XZ + a6b1WZ + a7b1XWZ + b2V + b3Q + a0b4V + a1b4XV + a2b4WV + a3b4ZV + a4b4XWV + a5b4XZV + a6b4WZV + a7b4XWZV + a0b5Q + a1b5XQ + a2b5WQ + a3b5ZQ + a4b5XWQ + a5b5XZQ + a6b5WZQ + a7b5XWZQ + b6VQ + a0b7VQ + a1b7XVQ + a2b7WVQ + a3b7ZVQ + a4b7XWVQ + a5b7XZVQ + a6b7WZVQ + a7b7XWZVQ + c1'X + c2'W + c3'Z + c4'XW + c5'XZ + c6'WZ + c7'XWZ


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

Y = (b0 + a0b1 + a2b1W + a3b1Z + a6b1WZ + b2V + b3Q + a0b4V + a2b4WV + a3b4ZV + a6b4WZV + a0b5Q + a2b5WQ + a3b5ZQ + a6b5WZQ + b6VQ + a0b7VQ + a2b7WVQ + a3b7ZVQ + a6b7WZVQ + c2'W + c3'Z + c6'WZ) + (a1b1 + a4b1W + a5b1Z + a7b1WZ + a1b4V + a4b4WV + a5b4ZV + a7b4WZV + a1b5Q + a4b5WQ + a5b5ZQ + a7b5WZQ + a1b7VQ+ a4b7WVQ + a5b7ZVQ + a7b7WZVQ + c1' + c4'W + c5'Z + c7'WZ)X


Hence...

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

a1b1 + a4b1W + a5b1Z + a7b1WZ + a1b4V + a4b4WV + a5b4ZV + a7b4WZV + a1b5Q + a4b5WQ + a5b5ZQ + a7b5WZQ + a1b7VQ+ a4b7WVQ + a5b7ZVQ + a7b7WZVQ = (a1 + a4W + a5Z + a7WZ)(b1 + b4V + b5Q + b7VQ)

One direct effect of X on Y, conditional on W, Z:

c1' + c4'W + c5'Z + c7'WZ

 

Mplus code for the model:

! Latent predictor variable X measured by X1-X4
! Latent mediator M measured by 4 observed variables M1-M4
! Latent moderators W, Z, V, and Q, each measured by sets of 4 observed variables W1-W4, Z1-Z4, V1-V4, and Q1-Q4 respectively
! Latent outcome variable Y measured by Y1-Y4

USEVARIABLES = X1 X2 X3 X4 M1 M2 M3 M4
W1 W2 W3 W4 Z1 Z2 Z3 Z4 V1 V2 V3 V4 Q1 Q2 Q3 Q4
Y1 Y2 Y3 Y4;

ANALYSIS:
   TYPE = GENERAL RANDOM;
   ESTIMATOR = ML;
   ALGORITHM = INTEGRATION;

! In model statement first state measurement model
! Then create any latent interactions required
! Then state structural model naming each path and intercept using parentheses

MODEL:

! Measurement model
! Identify moderator factors by fixing variance = 1 (instead of first loading)
! This makes these factors standardised
   X BY X1 X2 X3 X4;
   M BY M1 M2 M3 M4;
   W BY W1* W2 W3 W4;
   Z BY Z1* Z2 Z3 Z4;
   V BY V1* V2 V3 V4;
   Q BY Q1* Q2 Q3 Q4;
   Y BY Y1 Y2 Y3 Y4;

    W@1;   Z@1;   V@1;   Q@1;

! Create latent interactions
   MV | M XWITH V;
   MQ | M XWITH Q;
   XW | X XWITH W;
   XZ | X XWITH Z;
   WZ | W XWITH Z;
   VQ | V XWITH Q;
   MVQ | M XWITH VQ;
   XWZ | X XWITH WZ;

! Fit structural model and name parameters
! Note that intercepts of M, Y are fixed = 0 since they are latent vars
! so no code to state and name them as parameters
   Y ON M (b1);
   Y ON V (b2);
   Y ON Q (b3);
   Y ON MV (b4);
   Y ON MQ (b5);
   Y ON VQ (b6);
   Y ON MVQ (b7);

   Y ON X (cdash1);
   Y ON W (cdash2);
   Y ON Z (cdash3);
   Y ON XW (cdash4);
   Y ON XZ (cdash5);
   Y ON WZ (cdash6);
   Y ON XWZ (cdash7);

   M ON X (a1);
   M ON W (a2);
   M ON Z (a3);
   M ON XW (a4);
   M ON XZ (a5);
   M ON WZ (a6);
   M ON XWZ (a7);

! 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
    DLOW_LOZ DMEW_LOZ DHIW_LOZ DLOW_MEZ DMEW_MEZ DHIW_MEZ
    DLOW_HIZ DMEW_HIZ DHIW_HIZ
    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 = -1;   ! -1 SD below mean value of W
    MED_W = 0;   ! mean value of W
    HIGH_W = 1;   ! +1 SD above mean value of W

    LOW_Z = -1;   ! -1 SD below mean value of Z
    MED_Z = 0;   ! mean value of Z
    HIGH_Z = 1;   ! +1 SD above mean value of Z

    LOW_V = -1;   ! -1 SD below mean value of V
    MED_V = 0;   ! mean value of V
    HIGH_V = 1;   ! +1 SD above mean value of V

    LOW_Q = -1;   ! -1 SD below mean value of Q
    MED_Q = 0;   ! mean value of Q
    HIGH_Q = 1;   ! +1 SD above mean value of Q

! Calc conditional indirect effects for each combination of moderator values

    ILLLL = a1*b1 + a4*b1*LOW_W + a5*b1*LOW_Z + a7*b1*LOW_W*LOW_Z +
     a1*b4*LOW_V + a4*b4*LOW_W*LOW_V + a5*b4*LOW_Z*LOW_V +
     a7*b4*LOW_W*LOW_Z*LOW_V + a1*b5*LOW_Q + a4*b5*LOW_W*LOW_Q +
     a5*b5*LOW_Z*LOW_Q + a7*b5*LOW_W*LOW_Z*LOW_Q + a1*b7*LOW_V*LOW_Q +
     a4*b7*LOW_W*LOW_V*LOW_Q + a5*b7*LOW_Z*LOW_V*LOW_Q +
     a7*b7*LOW_W*LOW_Z*LOW_V*LOW_Q;
    IMLLL = a1*b1 + a4*b1*MED_W + a5*b1*LOW_Z + a7*b1*MED_W*LOW_Z +
     a1*b4*LOW_V + a4*b4*MED_W*LOW_V + a5*b4*LOW_Z*LOW_V +
     a7*b4*MED_W*LOW_Z*LOW_V + a1*b5*LOW_Q + a4*b5*MED_W*LOW_Q +
     a5*b5*LOW_Z*LOW_Q + a7*b5*MED_W*LOW_Z*LOW_Q + a1*b7*LOW_V*LOW_Q +
     a4*b7*MED_W*LOW_V*LOW_Q + a5*b7*LOW_Z*LOW_V*LOW_Q +
     a7*b7*MED_W*LOW_Z*LOW_V*LOW_Q;
    IHLLL = a1*b1 + a4*b1*HIGH_W + a5*b1*LOW_Z + a7*b1*HIGH_W*LOW_Z +
     a1*b4*LOW_V + a4*b4*HIGH_W*LOW_V + a5*b4*LOW_Z*LOW_V +
     a7*b4*HIGH_W*LOW_Z*LOW_V + a1*b5*LOW_Q + a4*b5*HIGH_W*LOW_Q +
     a5*b5*LOW_Z*LOW_Q + a7*b5*HIGH_W*LOW_Z*LOW_Q + a1*b7*LOW_V*LOW_Q +
     a4*b7*HIGH_W*LOW_V*LOW_Q + a5*b7*LOW_Z*LOW_V*LOW_Q +
     a7*b7*HIGH_W*LOW_Z*LOW_V*LOW_Q;

    ILMLL = a1*b1 + a4*b1*LOW_W + a5*b1*MED_Z + a7*b1*LOW_W*MED_Z +
     a1*b4*LOW_V + a4*b4*LOW_W*LOW_V + a5*b4*MED_Z*LOW_V +
     a7*b4*LOW_W*MED_Z*LOW_V + a1*b5*LOW_Q + a4*b5*LOW_W*LOW_Q +
     a5*b5*MED_Z*LOW_Q + a7*b5*LOW_W*MED_Z*LOW_Q + a1*b7*LOW_V*LOW_Q +
     a4*b7*LOW_W*LOW_V*LOW_Q + a5*b7*MED_Z*LOW_V*LOW_Q +
     a7*b7*LOW_W*MED_Z*LOW_V*LOW_Q;
    IMMLL = a1*b1 + a4*b1*MED_W + a5*b1*MED_Z + a7*b1*MED_W*MED_Z +
     a1*b4*LOW_V + a4*b4*MED_W*LOW_V + a5*b4*MED_Z*LOW_V +
     a7*b4*MED_W*MED_Z*LOW_V + a1*b5*LOW_Q + a4*b5*MED_W*LOW_Q +
     a5*b5*MED_Z*LOW_Q + a7*b5*MED_W*MED_Z*LOW_Q + a1*b7*LOW_V*LOW_Q +
     a4*b7*MED_W*LOW_V*LOW_Q + a5*b7*MED_Z*LOW_V*LOW_Q +
     a7*b7*MED_W*MED_Z*LOW_V*LOW_Q;
    IHMLL = a1*b1 + a4*b1*HIGH_W + a5*b1*MED_Z + a7*b1*HIGH_W*MED_Z +
     a1*b4*LOW_V + a4*b4*HIGH_W*LOW_V + a5*b4*MED_Z*LOW_V +
     a7*b4*HIGH_W*MED_Z*LOW_V + a1*b5*LOW_Q + a4*b5*HIGH_W*LOW_Q +
     a5*b5*MED_Z*LOW_Q + a7*b5*HIGH_W*MED_Z*LOW_Q + a1*b7*LOW_V*LOW_Q +
     a4*b7*HIGH_W*LOW_V*LOW_Q + a5*b7*MED_Z*LOW_V*LOW_Q +
     a7*b7*HIGH_W*MED_Z*LOW_V*LOW_Q;

    ILHLL = a1*b1 + a4*b1*LOW_W + a5*b1*HIGH_Z + a7*b1*LOW_W*HIGH_Z +
     a1*b4*LOW_V + a4*b4*LOW_W*LOW_V + a5*b4*HIGH_Z*LOW_V +
     a7*b4*LOW_W*HIGH_Z*LOW_V + a1*b5*LOW_Q + a4*b5*LOW_W*LOW_Q +
     a5*b5*HIGH_Z*LOW_Q + a7*b5*LOW_W*HIGH_Z*LOW_Q + a1*b7*LOW_V*LOW_Q +
     a4*b7*LOW_W*LOW_V*LOW_Q + a5*b7*HIGH_Z*LOW_V*LOW_Q +
     a7*b7*LOW_W*HIGH_Z*LOW_V*LOW_Q;
    IMHLL = a1*b1 + a4*b1*MED_W + a5*b1*HIGH_Z + a7*b1*MED_W*HIGH_Z +
     a1*b4*LOW_V + a4*b4*MED_W*LOW_V + a5*b4*HIGH_Z*LOW_V +
     a7*b4*MED_W*HIGH_Z*LOW_V + a1*b5*LOW_Q + a4*b5*MED_W*LOW_Q +
     a5*b5*HIGH_Z*LOW_Q + a7*b5*MED_W*HIGH_Z*LOW_Q + a1*b7*LOW_V*LOW_Q +
     a4*b7*MED_W*LOW_V*LOW_Q + a5*b7*HIGH_Z*LOW_V*LOW_Q +
     a7*b7*MED_W*HIGH_Z*LOW_V*LOW_Q;
    IHHLL = a1*b1 + a4*b1*HIGH_W + a5*b1*HIGH_Z + a7*b1*HIGH_W*HIGH_Z +
     a1*b4*LOW_V + a4*b4*HIGH_W*LOW_V + a5*b4*HIGH_Z*LOW_V +
     a7*b4*HIGH_W*HIGH_Z*LOW_V + a1*b5*LOW_Q + a4*b5*HIGH_W*LOW_Q +
     a5*b5*HIGH_Z*LOW_Q + a7*b5*HIGH_W*HIGH_Z*LOW_Q + a1*b7*LOW_V*LOW_Q +
     a4*b7*HIGH_W*LOW_V*LOW_Q + a5*b7*HIGH_Z*LOW_V*LOW_Q +
     a7*b7*HIGH_W*HIGH_Z*LOW_V*LOW_Q;

    ILLML = a1*b1 + a4*b1*LOW_W + a5*b1*LOW_Z + a7*b1*LOW_W*LOW_Z +
     a1*b4*MED_V + a4*b4*LOW_W*MED_V + a5*b4*LOW_Z*MED_V +
     a7*b4*LOW_W*LOW_Z*MED_V + a1*b5*LOW_Q + a4*b5*LOW_W*LOW_Q +
     a5*b5*LOW_Z*LOW_Q + a7*b5*LOW_W*LOW_Z*LOW_Q + a1*b7*MED_V*LOW_Q +
     a4*b7*LOW_W*MED_V*LOW_Q + a5*b7*LOW_Z*MED_V*LOW_Q +
     a7*b7*LOW_W*LOW_Z*MED_V*LOW_Q;
    IMLML = a1*b1 + a4*b1*MED_W + a5*b1*LOW_Z + a7*b1*MED_W*LOW_Z +
     a1*b4*MED_V + a4*b4*MED_W*MED_V + a5*b4*LOW_Z*MED_V +
     a7*b4*MED_W*LOW_Z*MED_V + a1*b5*LOW_Q + a4*b5*MED_W*LOW_Q +
     a5*b5*LOW_Z*LOW_Q + a7*b5*MED_W*LOW_Z*LOW_Q + a1*b7*MED_V*LOW_Q +
     a4*b7*MED_W*MED_V*LOW_Q + a5*b7*LOW_Z*MED_V*LOW_Q +
     a7*b7*MED_W*LOW_Z*MED_V*LOW_Q;
    IHLML = a1*b1 + a4*b1*HIGH_W + a5*b1*LOW_Z + a7*b1*HIGH_W*LOW_Z +
     a1*b4*MED_V + a4*b4*HIGH_W*MED_V + a5*b4*LOW_Z*MED_V +
     a7*b4*HIGH_W*LOW_Z*MED_V + a1*b5*LOW_Q + a4*b5*HIGH_W*LOW_Q +
     a5*b5*LOW_Z*LOW_Q + a7*b5*HIGH_W*LOW_Z*LOW_Q + a1*b7*MED_V*LOW_Q +
     a4*b7*HIGH_W*MED_V*LOW_Q + a5*b7*LOW_Z*MED_V*LOW_Q +
     a7*b7*HIGH_W*LOW_Z*MED_V*LOW_Q;

    ILMML = a1*b1 + a4*b1*LOW_W + a5*b1*MED_Z + a7*b1*LOW_W*MED_Z +
     a1*b4*MED_V + a4*b4*LOW_W*MED_V + a5*b4*MED_Z*MED_V +
     a7*b4*LOW_W*MED_Z*MED_V + a1*b5*LOW_Q + a4*b5*LOW_W*LOW_Q +
     a5*b5*MED_Z*LOW_Q + a7*b5*LOW_W*MED_Z*LOW_Q + a1*b7*MED_V*LOW_Q +
     a4*b7*LOW_W*MED_V*LOW_Q + a5*b7*MED_Z*MED_V*LOW_Q +
     a7*b7*LOW_W*MED_Z*MED_V*LOW_Q;
    IMMML = a1*b1 + a4*b1*MED_W + a5*b1*MED_Z + a7*b1*MED_W*MED_Z +
     a1*b4*MED_V + a4*b4*MED_W*MED_V + a5*b4*MED_Z*MED_V +
     a7*b4*MED_W*MED_Z*MED_V + a1*b5*LOW_Q + a4*b5*MED_W*LOW_Q +
     a5*b5*MED_Z*LOW_Q + a7*b5*MED_W*MED_Z*LOW_Q + a1*b7*MED_V*LOW_Q +
     a4*b7*MED_W*MED_V*LOW_Q + a5*b7*MED_Z*MED_V*LOW_Q +
     a7*b7*MED_W*MED_Z*MED_V*LOW_Q;
    IHMML = a1*b1 + a4*b1*HIGH_W + a5*b1*MED_Z + a7*b1*HIGH_W*MED_Z +
     a1*b4*MED_V + a4*b4*HIGH_W*MED_V + a5*b4*MED_Z*MED_V +
     a7*b4*HIGH_W*MED_Z*MED_V + a1*b5*LOW_Q + a4*b5*HIGH_W*LOW_Q +
     a5*b5*MED_Z*LOW_Q + a7*b5*HIGH_W*MED_Z*LOW_Q + a1*b7*MED_V*LOW_Q +
     a4*b7*HIGH_W*MED_V*LOW_Q + a5*b7*MED_Z*MED_V*LOW_Q +
     a7*b7*HIGH_W*MED_Z*MED_V*LOW_Q;

    ILHML = a1*b1 + a4*b1*LOW_W + a5*b1*HIGH_Z + a7*b1*LOW_W*HIGH_Z +
     a1*b4*MED_V + a4*b4*LOW_W*MED_V + a5*b4*HIGH_Z*MED_V +
     a7*b4*LOW_W*HIGH_Z*MED_V + a1*b5*LOW_Q + a4*b5*LOW_W*LOW_Q +
     a5*b5*HIGH_Z*LOW_Q + a7*b5*LOW_W*HIGH_Z*LOW_Q + a1*b7*MED_V*LOW_Q +
     a4*b7*LOW_W*MED_V*LOW_Q + a5*b7*HIGH_Z*MED_V*LOW_Q +
     a7*b7*LOW_W*HIGH_Z*MED_V*LOW_Q;
    IMHML = a1*b1 + a4*b1*MED_W + a5*b1*HIGH_Z + a7*b1*MED_W*HIGH_Z +
     a1*b4*MED_V + a4*b4*MED_W*MED_V + a5*b4*HIGH_Z*MED_V +
     a7*b4*MED_W*HIGH_Z*MED_V + a1*b5*LOW_Q + a4*b5*MED_W*LOW_Q +
     a5*b5*HIGH_Z*LOW_Q + a7*b5*MED_W*HIGH_Z*LOW_Q + a1*b7*MED_V*LOW_Q +
     a4*b7*MED_W*MED_V*LOW_Q + a5*b7*HIGH_Z*MED_V*LOW_Q +
     a7*b7*MED_W*HIGH_Z*MED_V*LOW_Q;
    IHHML = a1*b1 + a4*b1*HIGH_W + a5*b1*HIGH_Z + a7*b1*HIGH_W*HIGH_Z +
     a1*b4*MED_V + a4*b4*HIGH_W*MED_V + a5*b4*HIGH_Z*MED_V +
     a7*b4*HIGH_W*HIGH_Z*MED_V + a1*b5*LOW_Q + a4*b5*HIGH_W*LOW_Q +
     a5*b5*HIGH_Z*LOW_Q + a7*b5*HIGH_W*HIGH_Z*LOW_Q + a1*b7*MED_V*LOW_Q +
     a4*b7*HIGH_W*MED_V*LOW_Q + a5*b7*HIGH_Z*MED_V*LOW_Q +
     a7*b7*HIGH_W*HIGH_Z*MED_V*LOW_Q;

    ILLHL = a1*b1 + a4*b1*LOW_W + a5*b1*LOW_Z + a7*b1*LOW_W*LOW_Z +
     a1*b4*HIGH_V + a4*b4*LOW_W*HIGH_V + a5*b4*LOW_Z*HIGH_V +
     a7*b4*LOW_W*LOW_Z*HIGH_V + a1*b5*LOW_Q + a4*b5*LOW_W*LOW_Q +
     a5*b5*LOW_Z*LOW_Q + a7*b5*LOW_W*LOW_Z*LOW_Q + a1*b7*HIGH_V*LOW_Q +
     a4*b7*LOW_W*HIGH_V*LOW_Q + a5*b7*LOW_Z*HIGH_V*LOW_Q +
     a7*b7*LOW_W*LOW_Z*HIGH_V*LOW_Q;
    IMLHL = a1*b1 + a4*b1*MED_W + a5*b1*LOW_Z + a7*b1*MED_W*LOW_Z +
     a1*b4*HIGH_V + a4*b4*MED_W*HIGH_V + a5*b4*LOW_Z*HIGH_V +
     a7*b4*MED_W*LOW_Z*HIGH_V + a1*b5*LOW_Q + a4*b5*MED_W*LOW_Q +
     a5*b5*LOW_Z*LOW_Q + a7*b5*MED_W*LOW_Z*LOW_Q + a1*b7*HIGH_V*LOW_Q +
     a4*b7*MED_W*HIGH_V*LOW_Q + a5*b7*LOW_Z*HIGH_V*LOW_Q +
     a7*b7*MED_W*LOW_Z*HIGH_V*LOW_Q;
    IHLHL = a1*b1 + a4*b1*HIGH_W + a5*b1*LOW_Z + a7*b1*HIGH_W*LOW_Z +
     a1*b4*HIGH_V + a4*b4*HIGH_W*HIGH_V + a5*b4*LOW_Z*HIGH_V +
     a7*b4*HIGH_W*LOW_Z*HIGH_V + a1*b5*LOW_Q + a4*b5*HIGH_W*LOW_Q +
     a5*b5*LOW_Z*LOW_Q + a7*b5*HIGH_W*LOW_Z*LOW_Q + a1*b7*HIGH_V*LOW_Q +
     a4*b7*HIGH_W*HIGH_V*LOW_Q + a5*b7*LOW_Z*HIGH_V*LOW_Q +
     a7*b7*HIGH_W*LOW_Z*HIGH_V*LOW_Q;

    ILMHL = a1*b1 + a4*b1*LOW_W + a5*b1*MED_Z + a7*b1*LOW_W*MED_Z +
     a1*b4*HIGH_V + a4*b4*LOW_W*HIGH_V + a5*b4*MED_Z*HIGH_V +
     a7*b4*LOW_W*MED_Z*HIGH_V + a1*b5*LOW_Q + a4*b5*LOW_W*LOW_Q +
     a5*b5*MED_Z*LOW_Q + a7*b5*LOW_W*MED_Z*LOW_Q + a1*b7*HIGH_V*LOW_Q +
     a4*b7*LOW_W*HIGH_V*LOW_Q + a5*b7*MED_Z*HIGH_V*LOW_Q +
     a7*b7*LOW_W*MED_Z*HIGH_V*LOW_Q;
    IMMHL = a1*b1 + a4*b1*MED_W + a5*b1*MED_Z + a7*b1*MED_W*MED_Z +
     a1*b4*HIGH_V + a4*b4*MED_W*HIGH_V + a5*b4*MED_Z*HIGH_V +
     a7*b4*MED_W*MED_Z*HIGH_V + a1*b5*LOW_Q + a4*b5*MED_W*LOW_Q +
     a5*b5*MED_Z*LOW_Q + a7*b5*MED_W*MED_Z*LOW_Q + a1*b7*HIGH_V*LOW_Q +
     a4*b7*MED_W*HIGH_V*LOW_Q + a5*b7*MED_Z*HIGH_V*LOW_Q +
     a7*b7*MED_W*MED_Z*HIGH_V*LOW_Q;
    IHMHL = a1*b1 + a4*b1*HIGH_W + a5*b1*MED_Z + a7*b1*HIGH_W*MED_Z +
     a1*b4*HIGH_V + a4*b4*HIGH_W*HIGH_V + a5*b4*MED_Z*HIGH_V +
     a7*b4*HIGH_W*MED_Z*HIGH_V + a1*b5*LOW_Q + a4*b5*HIGH_W*LOW_Q +
     a5*b5*MED_Z*LOW_Q + a7*b5*HIGH_W*MED_Z*LOW_Q + a1*b7*HIGH_V*LOW_Q +
     a4*b7*HIGH_W*HIGH_V*LOW_Q + a5*b7*MED_Z*HIGH_V*LOW_Q +
     a7*b7*HIGH_W*MED_Z*HIGH_V*LOW_Q;

    ILHHL = a1*b1 + a4*b1*LOW_W + a5*b1*HIGH_Z + a7*b1*LOW_W*HIGH_Z +
     a1*b4*HIGH_V + a4*b4*LOW_W*HIGH_V + a5*b4*HIGH_Z*HIGH_V +
     a7*b4*LOW_W*HIGH_Z*HIGH_V + a1*b5*LOW_Q + a4*b5*LOW_W*LOW_Q +
     a5*b5*HIGH_Z*LOW_Q + a7*b5*LOW_W*HIGH_Z*LOW_Q + a1*b7*HIGH_V*LOW_Q +
     a4*b7*LOW_W*HIGH_V*LOW_Q + a5*b7*HIGH_Z*HIGH_V*LOW_Q +
     a7*b7*LOW_W*HIGH_Z*HIGH_V*LOW_Q;
    IMHHL = a1*b1 + a4*b1*MED_W + a5*b1*HIGH_Z + a7*b1*MED_W*HIGH_Z +
     a1*b4*HIGH_V + a4*b4*MED_W*HIGH_V + a5*b4*HIGH_Z*HIGH_V +
     a7*b4*MED_W*HIGH_Z*HIGH_V + a1*b5*LOW_Q + a4*b5*MED_W*LOW_Q +
     a5*b5*HIGH_Z*LOW_Q + a7*b5*MED_W*HIGH_Z*LOW_Q + a1*b7*HIGH_V*LOW_Q +
     a4*b7*MED_W*HIGH_V*LOW_Q + a5*b7*HIGH_Z*HIGH_V*LOW_Q +
     a7*b7*MED_W*HIGH_Z*HIGH_V*LOW_Q;
    IHHHL = a1*b1 + a4*b1*HIGH_W + a5*b1*HIGH_Z + a7*b1*HIGH_W*HIGH_Z +
     a1*b4*HIGH_V + a4*b4*HIGH_W*HIGH_V + a5*b4*HIGH_Z*HIGH_V +
     a7*b4*HIGH_W*HIGH_Z*HIGH_V + a1*b5*LOW_Q + a4*b5*HIGH_W*LOW_Q +
     a5*b5*HIGH_Z*LOW_Q + a7*b5*HIGH_W*HIGH_Z*LOW_Q + a1*b7*HIGH_V*LOW_Q +
     a4*b7*HIGH_W*HIGH_V*LOW_Q + a5*b7*HIGH_Z*HIGH_V*LOW_Q +
     a7*b7*HIGH_W*HIGH_Z*HIGH_V*LOW_Q;

    ILLLM = a1*b1 + a4*b1*LOW_W + a5*b1*LOW_Z + a7*b1*LOW_W*LOW_Z +
     a1*b4*LOW_V + a4*b4*LOW_W*LOW_V + a5*b4*LOW_Z*LOW_V +
     a7*b4*LOW_W*LOW_Z*LOW_V + a1*b5*MED_Q + a4*b5*LOW_W*MED_Q +
     a5*b5*LOW_Z*MED_Q + a7*b5*LOW_W*LOW_Z*MED_Q + a1*b7*LOW_V*MED_Q +
     a4*b7*LOW_W*LOW_V*MED_Q + a5*b7*LOW_Z*LOW_V*MED_Q +
     a7*b7*LOW_W*LOW_Z*LOW_V*MED_Q;
    IMLLM = a1*b1 + a4*b1*MED_W + a5*b1*LOW_Z + a7*b1*MED_W*LOW_Z +
     a1*b4*LOW_V + a4*b4*MED_W*LOW_V + a5*b4*LOW_Z*LOW_V +
     a7*b4*MED_W*LOW_Z*LOW_V + a1*b5*MED_Q + a4*b5*MED_W*MED_Q +
     a5*b5*LOW_Z*MED_Q + a7*b5*MED_W*LOW_Z*MED_Q + a1*b7*LOW_V*MED_Q +
     a4*b7*MED_W*LOW_V*MED_Q + a5*b7*LOW_Z*LOW_V*MED_Q +
     a7*b7*MED_W*LOW_Z*LOW_V*MED_Q;
    IHLLM = a1*b1 + a4*b1*HIGH_W + a5*b1*LOW_Z + a7*b1*HIGH_W*LOW_Z +
     a1*b4*LOW_V + a4*b4*HIGH_W*LOW_V + a5*b4*LOW_Z*LOW_V +
     a7*b4*HIGH_W*LOW_Z*LOW_V + a1*b5*MED_Q + a4*b5*HIGH_W*MED_Q +
     a5*b5*LOW_Z*MED_Q + a7*b5*HIGH_W*LOW_Z*MED_Q + a1*b7*LOW_V*MED_Q +
     a4*b7*HIGH_W*LOW_V*MED_Q + a5*b7*LOW_Z*LOW_V*MED_Q +
     a7*b7*HIGH_W*LOW_Z*LOW_V*MED_Q;

    ILMLM = a1*b1 + a4*b1*LOW_W + a5*b1*MED_Z + a7*b1*LOW_W*MED_Z +
     a1*b4*LOW_V + a4*b4*LOW_W*LOW_V + a5*b4*MED_Z*LOW_V +
     a7*b4*LOW_W*MED_Z*LOW_V + a1*b5*MED_Q + a4*b5*LOW_W*MED_Q +
     a5*b5*MED_Z*MED_Q + a7*b5*LOW_W*MED_Z*MED_Q + a1*b7*LOW_V*MED_Q +
     a4*b7*LOW_W*LOW_V*MED_Q + a5*b7*MED_Z*LOW_V*MED_Q +
     a7*b7*LOW_W*MED_Z*LOW_V*MED_Q;
    IMMLM = a1*b1 + a4*b1*MED_W + a5*b1*MED_Z + a7*b1*MED_W*MED_Z +
     a1*b4*LOW_V + a4*b4*MED_W*LOW_V + a5*b4*MED_Z*LOW_V +
     a7*b4*MED_W*MED_Z*LOW_V + a1*b5*MED_Q + a4*b5*MED_W*MED_Q +
     a5*b5*MED_Z*MED_Q + a7*b5*MED_W*MED_Z*MED_Q + a1*b7*LOW_V*MED_Q +
     a4*b7*MED_W*LOW_V*MED_Q + a5*b7*MED_Z*LOW_V*MED_Q +
     a7*b7*MED_W*MED_Z*LOW_V*MED_Q;
    IHMLM = a1*b1 + a4*b1*HIGH_W + a5*b1*MED_Z + a7*b1*HIGH_W*MED_Z +
     a1*b4*LOW_V + a4*b4*HIGH_W*LOW_V + a5*b4*MED_Z*LOW_V +
     a7*b4*HIGH_W*MED_Z*LOW_V + a1*b5*MED_Q + a4*b5*HIGH_W*MED_Q +
     a5*b5*MED_Z*MED_Q + a7*b5*HIGH_W*MED_Z*MED_Q + a1*b7*LOW_V*MED_Q +
     a4*b7*HIGH_W*LOW_V*MED_Q + a5*b7*MED_Z*LOW_V*MED_Q +
     a7*b7*HIGH_W*MED_Z*LOW_V*MED_Q;

    ILHLM = a1*b1 + a4*b1*LOW_W + a5*b1*HIGH_Z + a7*b1*LOW_W*HIGH_Z +
     a1*b4*LOW_V + a4*b4*LOW_W*LOW_V + a5*b4*HIGH_Z*LOW_V +
     a7*b4*LOW_W*HIGH_Z*LOW_V + a1*b5*MED_Q + a4*b5*LOW_W*MED_Q +
     a5*b5*HIGH_Z*MED_Q + a7*b5*LOW_W*HIGH_Z*MED_Q + a1*b7*LOW_V*MED_Q +
     a4*b7*LOW_W*LOW_V*MED_Q + a5*b7*HIGH_Z*LOW_V*MED_Q +
     a7*b7*LOW_W*HIGH_Z*LOW_V*MED_Q;
    IMHLM = a1*b1 + a4*b1*MED_W + a5*b1*HIGH_Z + a7*b1*MED_W*HIGH_Z +
     a1*b4*LOW_V + a4*b4*MED_W*LOW_V + a5*b4*HIGH_Z*LOW_V +
     a7*b4*MED_W*HIGH_Z*LOW_V + a1*b5*MED_Q + a4*b5*MED_W*MED_Q +
     a5*b5*HIGH_Z*MED_Q + a7*b5*MED_W*HIGH_Z*MED_Q + a1*b7*LOW_V*MED_Q +
     a4*b7*MED_W*LOW_V*MED_Q + a5*b7*HIGH_Z*LOW_V*MED_Q +
     a7*b7*MED_W*HIGH_Z*LOW_V*MED_Q;
    IHHLM = a1*b1 + a4*b1*HIGH_W + a5*b1*HIGH_Z + a7*b1*HIGH_W*HIGH_Z +
     a1*b4*LOW_V + a4*b4*HIGH_W*LOW_V + a5*b4*HIGH_Z*LOW_V +
     a7*b4*HIGH_W*HIGH_Z*LOW_V + a1*b5*MED_Q + a4*b5*HIGH_W*MED_Q +
     a5*b5*HIGH_Z*MED_Q + a7*b5*HIGH_W*HIGH_Z*MED_Q + a1*b7*LOW_V*MED_Q +
     a4*b7*HIGH_W*LOW_V*MED_Q + a5*b7*HIGH_Z*LOW_V*MED_Q +
     a7*b7*HIGH_W*HIGH_Z*LOW_V*MED_Q;

    ILLMM = a1*b1 + a4*b1*LOW_W + a5*b1*LOW_Z + a7*b1*LOW_W*LOW_Z +
     a1*b4*MED_V + a4*b4*LOW_W*MED_V + a5*b4*LOW_Z*MED_V +
     a7*b4*LOW_W*LOW_Z*MED_V + a1*b5*MED_Q + a4*b5*LOW_W*MED_Q +
     a5*b5*LOW_Z*MED_Q + a7*b5*LOW_W*LOW_Z*MED_Q + a1*b7*MED_V*MED_Q +
     a4*b7*LOW_W*MED_V*MED_Q + a5*b7*LOW_Z*MED_V*MED_Q +
     a7*b7*LOW_W*LOW_Z*MED_V*MED_Q;
    IMLMM = a1*b1 + a4*b1*MED_W + a5*b1*LOW_Z + a7*b1*MED_W*LOW_Z +
     a1*b4*MED_V + a4*b4*MED_W*MED_V + a5*b4*LOW_Z*MED_V +
     a7*b4*MED_W*LOW_Z*MED_V + a1*b5*MED_Q + a4*b5*MED_W*MED_Q +
     a5*b5*LOW_Z*MED_Q + a7*b5*MED_W*LOW_Z*MED_Q + a1*b7*MED_V*MED_Q +
     a4*b7*MED_W*MED_V*MED_Q + a5*b7*LOW_Z*MED_V*MED_Q +
     a7*b7*MED_W*LOW_Z*MED_V*MED_Q;
    IHLMM = a1*b1 + a4*b1*HIGH_W + a5*b1*LOW_Z + a7*b1*HIGH_W*LOW_Z +
     a1*b4*MED_V + a4*b4*HIGH_W*MED_V + a5*b4*LOW_Z*MED_V +
     a7*b4*HIGH_W*LOW_Z*MED_V + a1*b5*MED_Q + a4*b5*HIGH_W*MED_Q +
     a5*b5*LOW_Z*MED_Q + a7*b5*HIGH_W*LOW_Z*MED_Q + a1*b7*MED_V*MED_Q +
     a4*b7*HIGH_W*MED_V*MED_Q + a5*b7*LOW_Z*MED_V*MED_Q +
     a7*b7*HIGH_W*LOW_Z*MED_V*MED_Q;

    ILMMM = a1*b1 + a4*b1*LOW_W + a5*b1*MED_Z + a7*b1*LOW_W*MED_Z +
     a1*b4*MED_V + a4*b4*LOW_W*MED_V + a5*b4*MED_Z*MED_V +
     a7*b4*LOW_W*MED_Z*MED_V + a1*b5*MED_Q + a4*b5*LOW_W*MED_Q +
     a5*b5*MED_Z*MED_Q + a7*b5*LOW_W*MED_Z*MED_Q + a1*b7*MED_V*MED_Q +
     a4*b7*LOW_W*MED_V*MED_Q + a5*b7*MED_Z*MED_V*MED_Q +
     a7*b7*LOW_W*MED_Z*MED_V*MED_Q;
    IMMMM = a1*b1 + a4*b1*MED_W + a5*b1*MED_Z + a7*b1*MED_W*MED_Z +
     a1*b4*MED_V + a4*b4*MED_W*MED_V + a5*b4*MED_Z*MED_V +
     a7*b4*MED_W*MED_Z*MED_V + a1*b5*MED_Q + a4*b5*MED_W*MED_Q +
     a5*b5*MED_Z*MED_Q + a7*b5*MED_W*MED_Z*MED_Q + a1*b7*MED_V*MED_Q +
     a4*b7*MED_W*MED_V*MED_Q + a5*b7*MED_Z*MED_V*MED_Q +
     a7*b7*MED_W*MED_Z*MED_V*MED_Q;
    IHMMM = a1*b1 + a4*b1*HIGH_W + a5*b1*MED_Z + a7*b1*HIGH_W*MED_Z +
     a1*b4*MED_V + a4*b4*HIGH_W*MED_V + a5*b4*MED_Z*MED_V +
     a7*b4*HIGH_W*MED_Z*MED_V + a1*b5*MED_Q + a4*b5*HIGH_W*MED_Q +
     a5*b5*MED_Z*MED_Q + a7*b5*HIGH_W*MED_Z*MED_Q + a1*b7*MED_V*MED_Q +
     a4*b7*HIGH_W*MED_V*MED_Q + a5*b7*MED_Z*MED_V*MED_Q +
     a7*b7*HIGH_W*MED_Z*MED_V*MED_Q;

    ILHMM = a1*b1 + a4*b1*LOW_W + a5*b1*HIGH_Z + a7*b1*LOW_W*HIGH_Z +
     a1*b4*MED_V + a4*b4*LOW_W*MED_V + a5*b4*HIGH_Z*MED_V +
     a7*b4*LOW_W*HIGH_Z*MED_V + a1*b5*MED_Q + a4*b5*LOW_W*MED_Q +
     a5*b5*HIGH_Z*MED_Q + a7*b5*LOW_W*HIGH_Z*MED_Q + a1*b7*MED_V*MED_Q +
     a4*b7*LOW_W*MED_V*MED_Q + a5*b7*HIGH_Z*MED_V*MED_Q +
     a7*b7*LOW_W*HIGH_Z*MED_V*MED_Q;
    IMHMM = a1*b1 + a4*b1*MED_W + a5*b1*HIGH_Z + a7*b1*MED_W*HIGH_Z +
     a1*b4*MED_V + a4*b4*MED_W*MED_V + a5*b4*HIGH_Z*MED_V +
     a7*b4*MED_W*HIGH_Z*MED_V + a1*b5*MED_Q + a4*b5*MED_W*MED_Q +
     a5*b5*HIGH_Z*MED_Q + a7*b5*MED_W*HIGH_Z*MED_Q + a1*b7*MED_V*MED_Q +
     a4*b7*MED_W*MED_V*MED_Q + a5*b7*HIGH_Z*MED_V*MED_Q +
     a7*b7*MED_W*HIGH_Z*MED_V*MED_Q;
    IHHMM = a1*b1 + a4*b1*HIGH_W + a5*b1*HIGH_Z + a7*b1*HIGH_W*HIGH_Z +
     a1*b4*MED_V + a4*b4*HIGH_W*MED_V + a5*b4*HIGH_Z*MED_V +
     a7*b4*HIGH_W*HIGH_Z*MED_V + a1*b5*MED_Q + a4*b5*HIGH_W*MED_Q +
     a5*b5*HIGH_Z*MED_Q + a7*b5*HIGH_W*HIGH_Z*MED_Q + a1*b7*MED_V*MED_Q +
     a4*b7*HIGH_W*MED_V*MED_Q + a5*b7*HIGH_Z*MED_V*MED_Q +
     a7*b7*HIGH_W*HIGH_Z*MED_V*MED_Q;

    ILLHM = a1*b1 + a4*b1*LOW_W + a5*b1*LOW_Z + a7*b1*LOW_W*LOW_Z +
     a1*b4*HIGH_V + a4*b4*LOW_W*HIGH_V + a5*b4*LOW_Z*HIGH_V +
     a7*b4*LOW_W*LOW_Z*HIGH_V + a1*b5*MED_Q + a4*b5*LOW_W*MED_Q +
     a5*b5*LOW_Z*MED_Q + a7*b5*LOW_W*LOW_Z*MED_Q + a1*b7*HIGH_V*MED_Q +
     a4*b7*LOW_W*HIGH_V*MED_Q + a5*b7*LOW_Z*HIGH_V*MED_Q +
     a7*b7*LOW_W*LOW_Z*HIGH_V*MED_Q;
    IMLHM = a1*b1 + a4*b1*MED_W + a5*b1*LOW_Z + a7*b1*MED_W*LOW_Z +
     a1*b4*HIGH_V + a4*b4*MED_W*HIGH_V + a5*b4*LOW_Z*HIGH_V +
     a7*b4*MED_W*LOW_Z*HIGH_V + a1*b5*MED_Q + a4*b5*MED_W*MED_Q +
     a5*b5*LOW_Z*MED_Q + a7*b5*MED_W*LOW_Z*MED_Q + a1*b7*HIGH_V*MED_Q +
     a4*b7*MED_W*HIGH_V*MED_Q + a5*b7*LOW_Z*HIGH_V*MED_Q +
     a7*b7*MED_W*LOW_Z*HIGH_V*MED_Q;
    IHLHM = a1*b1 + a4*b1*HIGH_W + a5*b1*LOW_Z + a7*b1*HIGH_W*LOW_Z +
     a1*b4*HIGH_V + a4*b4*HIGH_W*HIGH_V + a5*b4*LOW_Z*HIGH_V +
     a7*b4*HIGH_W*LOW_Z*HIGH_V + a1*b5*MED_Q + a4*b5*HIGH_W*MED_Q +
     a5*b5*LOW_Z*MED_Q + a7*b5*HIGH_W*LOW_Z*MED_Q + a1*b7*HIGH_V*MED_Q +
     a4*b7*HIGH_W*HIGH_V*MED_Q + a5*b7*LOW_Z*HIGH_V*MED_Q +
     a7*b7*HIGH_W*LOW_Z*HIGH_V*MED_Q;

    ILMHM = a1*b1 + a4*b1*LOW_W + a5*b1*MED_Z + a7*b1*LOW_W*MED_Z +
     a1*b4*HIGH_V + a4*b4*LOW_W*HIGH_V + a5*b4*MED_Z*HIGH_V +
     a7*b4*LOW_W*MED_Z*HIGH_V + a1*b5*MED_Q + a4*b5*LOW_W*MED_Q +
     a5*b5*MED_Z*MED_Q + a7*b5*LOW_W*MED_Z*MED_Q + a1*b7*HIGH_V*MED_Q +
     a4*b7*LOW_W*HIGH_V*MED_Q + a5*b7*MED_Z*HIGH_V*MED_Q +
     a7*b7*LOW_W*MED_Z*HIGH_V*MED_Q;
    IMMHM = a1*b1 + a4*b1*MED_W + a5*b1*MED_Z + a7*b1*MED_W*MED_Z +
     a1*b4*HIGH_V + a4*b4*MED_W*HIGH_V + a5*b4*MED_Z*HIGH_V +
     a7*b4*MED_W*MED_Z*HIGH_V + a1*b5*MED_Q + a4*b5*MED_W*MED_Q +
     a5*b5*MED_Z*MED_Q + a7*b5*MED_W*MED_Z*MED_Q + a1*b7*HIGH_V*MED_Q +
     a4*b7*MED_W*HIGH_V*MED_Q + a5*b7*MED_Z*HIGH_V*MED_Q +
     a7*b7*MED_W*MED_Z*HIGH_V*MED_Q;
    IHMHM = a1*b1 + a4*b1*HIGH_W + a5*b1*MED_Z + a7*b1*HIGH_W*MED_Z +
     a1*b4*HIGH_V + a4*b4*HIGH_W*HIGH_V + a5*b4*MED_Z*HIGH_V +
     a7*b4*HIGH_W*MED_Z*HIGH_V + a1*b5*MED_Q + a4*b5*HIGH_W*MED_Q +
     a5*b5*MED_Z*MED_Q + a7*b5*HIGH_W*MED_Z*MED_Q + a1*b7*HIGH_V*MED_Q +
     a4*b7*HIGH_W*HIGH_V*MED_Q + a5*b7*MED_Z*HIGH_V*MED_Q +
     a7*b7*HIGH_W*MED_Z*HIGH_V*MED_Q;

    ILHHM = a1*b1 + a4*b1*LOW_W + a5*b1*HIGH_Z + a7*b1*LOW_W*HIGH_Z +
     a1*b4*HIGH_V + a4*b4*LOW_W*HIGH_V + a5*b4*HIGH_Z*HIGH_V +
     a7*b4*LOW_W*HIGH_Z*HIGH_V + a1*b5*MED_Q + a4*b5*LOW_W*MED_Q +
     a5*b5*HIGH_Z*MED_Q + a7*b5*LOW_W*HIGH_Z*MED_Q + a1*b7*HIGH_V*MED_Q +
     a4*b7*LOW_W*HIGH_V*MED_Q + a5*b7*HIGH_Z*HIGH_V*MED_Q +
     a7*b7*LOW_W*HIGH_Z*HIGH_V*MED_Q;
    IMHHM = a1*b1 + a4*b1*MED_W + a5*b1*HIGH_Z + a7*b1*MED_W*HIGH_Z +
     a1*b4*HIGH_V + a4*b4*MED_W*HIGH_V + a5*b4*HIGH_Z*HIGH_V +
     a7*b4*MED_W*HIGH_Z*HIGH_V + a1*b5*MED_Q + a4*b5*MED_W*MED_Q +
     a5*b5*HIGH_Z*MED_Q + a7*b5*MED_W*HIGH_Z*MED_Q + a1*b7*HIGH_V*MED_Q +
     a4*b7*MED_W*HIGH_V*MED_Q + a5*b7*HIGH_Z*HIGH_V*MED_Q +
     a7*b7*MED_W*HIGH_Z*HIGH_V*MED_Q;
    IHHHM = a1*b1 + a4*b1*HIGH_W + a5*b1*HIGH_Z + a7*b1*HIGH_W*HIGH_Z +
     a1*b4*HIGH_V + a4*b4*HIGH_W*HIGH_V + a5*b4*HIGH_Z*HIGH_V +
     a7*b4*HIGH_W*HIGH_Z*HIGH_V + a1*b5*MED_Q + a4*b5*HIGH_W*MED_Q +
     a5*b5*HIGH_Z*MED_Q + a7*b5*HIGH_W*HIGH_Z*MED_Q + a1*b7*HIGH_V*MED_Q +
     a4*b7*HIGH_W*HIGH_V*MED_Q + a5*b7*HIGH_Z*HIGH_V*MED_Q +
     a7*b7*HIGH_W*HIGH_Z*HIGH_V*MED_Q;

    ILLLH = a1*b1 + a4*b1*LOW_W + a5*b1*LOW_Z + a7*b1*LOW_W*LOW_Z +
     a1*b4*LOW_V + a4*b4*LOW_W*LOW_V + a5*b4*LOW_Z*LOW_V +
     a7*b4*LOW_W*LOW_Z*LOW_V + a1*b5*HIGH_Q + a4*b5*LOW_W*HIGH_Q +
     a5*b5*LOW_Z*HIGH_Q + a7*b5*LOW_W*LOW_Z*HIGH_Q + a1*b7*LOW_V*HIGH_Q +
     a4*b7*LOW_W*LOW_V*HIGH_Q + a5*b7*LOW_Z*LOW_V*HIGH_Q +
     a7*b7*LOW_W*LOW_Z*LOW_V*HIGH_Q;
    IMLLH = a1*b1 + a4*b1*MED_W + a5*b1*LOW_Z + a7*b1*MED_W*LOW_Z +
     a1*b4*LOW_V + a4*b4*MED_W*LOW_V + a5*b4*LOW_Z*LOW_V +
     a7*b4*MED_W*LOW_Z*LOW_V + a1*b5*HIGH_Q + a4*b5*MED_W*HIGH_Q +
     a5*b5*LOW_Z*HIGH_Q + a7*b5*MED_W*LOW_Z*HIGH_Q + a1*b7*LOW_V*HIGH_Q +
     a4*b7*MED_W*LOW_V*HIGH_Q + a5*b7*LOW_Z*LOW_V*HIGH_Q +
     a7*b7*MED_W*LOW_Z*LOW_V*HIGH_Q;
    IHLLH = a1*b1 + a4*b1*HIGH_W + a5*b1*LOW_Z + a7*b1*HIGH_W*LOW_Z +
     a1*b4*LOW_V + a4*b4*HIGH_W*LOW_V + a5*b4*LOW_Z*LOW_V +
     a7*b4*HIGH_W*LOW_Z*LOW_V + a1*b5*HIGH_Q + a4*b5*HIGH_W*HIGH_Q +
     a5*b5*LOW_Z*HIGH_Q + a7*b5*HIGH_W*LOW_Z*HIGH_Q + a1*b7*LOW_V*HIGH_Q +
     a4*b7*HIGH_W*LOW_V*HIGH_Q + a5*b7*LOW_Z*LOW_V*HIGH_Q +
     a7*b7*HIGH_W*LOW_Z*LOW_V*HIGH_Q;

    ILMLH = a1*b1 + a4*b1*LOW_W + a5*b1*MED_Z + a7*b1*LOW_W*MED_Z +
     a1*b4*LOW_V + a4*b4*LOW_W*LOW_V + a5*b4*MED_Z*LOW_V +
     a7*b4*LOW_W*MED_Z*LOW_V + a1*b5*HIGH_Q + a4*b5*LOW_W*HIGH_Q +
     a5*b5*MED_Z*HIGH_Q + a7*b5*LOW_W*MED_Z*HIGH_Q + a1*b7*LOW_V*HIGH_Q +
     a4*b7*LOW_W*LOW_V*HIGH_Q + a5*b7*MED_Z*LOW_V*HIGH_Q +
     a7*b7*LOW_W*MED_Z*LOW_V*HIGH_Q;
    IMMLH = a1*b1 + a4*b1*MED_W + a5*b1*MED_Z + a7*b1*MED_W*MED_Z +
     a1*b4*LOW_V + a4*b4*MED_W*LOW_V + a5*b4*MED_Z*LOW_V +
     a7*b4*MED_W*MED_Z*LOW_V + a1*b5*HIGH_Q + a4*b5*MED_W*HIGH_Q +
     a5*b5*MED_Z*HIGH_Q + a7*b5*MED_W*MED_Z*HIGH_Q + a1*b7*LOW_V*HIGH_Q +
     a4*b7*MED_W*LOW_V*HIGH_Q + a5*b7*MED_Z*LOW_V*HIGH_Q +
     a7*b7*MED_W*MED_Z*LOW_V*HIGH_Q;
    IHMLH = a1*b1 + a4*b1*HIGH_W + a5*b1*MED_Z + a7*b1*HIGH_W*MED_Z +
     a1*b4*LOW_V + a4*b4*HIGH_W*LOW_V + a5*b4*MED_Z*LOW_V +
     a7*b4*HIGH_W*MED_Z*LOW_V + a1*b5*HIGH_Q + a4*b5*HIGH_W*HIGH_Q +
     a5*b5*MED_Z*HIGH_Q + a7*b5*HIGH_W*MED_Z*HIGH_Q + a1*b7*LOW_V*HIGH_Q +
     a4*b7*HIGH_W*LOW_V*HIGH_Q + a5*b7*MED_Z*LOW_V*HIGH_Q +
     a7*b7*HIGH_W*MED_Z*LOW_V*HIGH_Q;

    ILHLH = a1*b1 + a4*b1*LOW_W + a5*b1*HIGH_Z + a7*b1*LOW_W*HIGH_Z +
     a1*b4*LOW_V + a4*b4*LOW_W*LOW_V + a5*b4*HIGH_Z*LOW_V +
     a7*b4*LOW_W*HIGH_Z*LOW_V + a1*b5*HIGH_Q + a4*b5*LOW_W*HIGH_Q +
     a5*b5*HIGH_Z*HIGH_Q + a7*b5*LOW_W*HIGH_Z*HIGH_Q + a1*b7*LOW_V*HIGH_Q +
     a4*b7*LOW_W*LOW_V*HIGH_Q + a5*b7*HIGH_Z*LOW_V*HIGH_Q +
     a7*b7*LOW_W*HIGH_Z*LOW_V*HIGH_Q;
    IMHLH = a1*b1 + a4*b1*MED_W + a5*b1*HIGH_Z + a7*b1*MED_W*HIGH_Z +
     a1*b4*LOW_V + a4*b4*MED_W*LOW_V + a5*b4*HIGH_Z*LOW_V +
     a7*b4*MED_W*HIGH_Z*LOW_V + a1*b5*HIGH_Q + a4*b5*MED_W*HIGH_Q +
     a5*b5*HIGH_Z*HIGH_Q + a7*b5*MED_W*HIGH_Z*HIGH_Q + a1*b7*LOW_V*HIGH_Q +
     a4*b7*MED_W*LOW_V*HIGH_Q + a5*b7*HIGH_Z*LOW_V*HIGH_Q +
     a7*b7*MED_W*HIGH_Z*LOW_V*HIGH_Q;
    IHHLH = a1*b1 + a4*b1*HIGH_W + a5*b1*HIGH_Z + a7*b1*HIGH_W*HIGH_Z +
     a1*b4*LOW_V + a4*b4*HIGH_W*LOW_V + a5*b4*HIGH_Z*LOW_V +
     a7*b4*HIGH_W*HIGH_Z*LOW_V + a1*b5*HIGH_Q + a4*b5*HIGH_W*HIGH_Q +
     a5*b5*HIGH_Z*HIGH_Q + a7*b5*HIGH_W*HIGH_Z*HIGH_Q + a1*b7*LOW_V*HIGH_Q +
     a4*b7*HIGH_W*LOW_V*HIGH_Q + a5*b7*HIGH_Z*LOW_V*HIGH_Q +
     a7*b7*HIGH_W*HIGH_Z*LOW_V*HIGH_Q;

    ILLMH = a1*b1 + a4*b1*LOW_W + a5*b1*LOW_Z + a7*b1*LOW_W*LOW_Z +
     a1*b4*MED_V + a4*b4*LOW_W*MED_V + a5*b4*LOW_Z*MED_V +
     a7*b4*LOW_W*LOW_Z*MED_V + a1*b5*HIGH_Q + a4*b5*LOW_W*HIGH_Q +
     a5*b5*LOW_Z*HIGH_Q + a7*b5*LOW_W*LOW_Z*HIGH_Q + a1*b7*MED_V*HIGH_Q +
     a4*b7*LOW_W*MED_V*HIGH_Q + a5*b7*LOW_Z*MED_V*HIGH_Q +
     a7*b7*LOW_W*LOW_Z*MED_V*HIGH_Q;
    IMLMH = a1*b1 + a4*b1*MED_W + a5*b1*LOW_Z + a7*b1*MED_W*LOW_Z +
     a1*b4*MED_V + a4*b4*MED_W*MED_V + a5*b4*LOW_Z*MED_V +
     a7*b4*MED_W*LOW_Z*MED_V + a1*b5*HIGH_Q + a4*b5*MED_W*HIGH_Q +
     a5*b5*LOW_Z*HIGH_Q + a7*b5*MED_W*LOW_Z*HIGH_Q + a1*b7*MED_V*HIGH_Q +
     a4*b7*MED_W*MED_V*HIGH_Q + a5*b7*LOW_Z*MED_V*HIGH_Q +
     a7*b7*MED_W*LOW_Z*MED_V*HIGH_Q;
    IHLMH = a1*b1 + a4*b1*HIGH_W + a5*b1*LOW_Z + a7*b1*HIGH_W*LOW_Z +
     a1*b4*MED_V + a4*b4*HIGH_W*MED_V + a5*b4*LOW_Z*MED_V +
     a7*b4*HIGH_W*LOW_Z*MED_V + a1*b5*HIGH_Q + a4*b5*HIGH_W*HIGH_Q +
     a5*b5*LOW_Z*HIGH_Q + a7*b5*HIGH_W*LOW_Z*HIGH_Q + a1*b7*MED_V*HIGH_Q +
     a4*b7*HIGH_W*MED_V*HIGH_Q + a5*b7*LOW_Z*MED_V*HIGH_Q +
     a7*b7*HIGH_W*LOW_Z*MED_V*HIGH_Q;

    ILMMH = a1*b1 + a4*b1*LOW_W + a5*b1*MED_Z + a7*b1*LOW_W*MED_Z +
     a1*b4*MED_V + a4*b4*LOW_W*MED_V + a5*b4*MED_Z*MED_V +
     a7*b4*LOW_W*MED_Z*MED_V + a1*b5*HIGH_Q + a4*b5*LOW_W*HIGH_Q +
     a5*b5*MED_Z*HIGH_Q + a7*b5*LOW_W*MED_Z*HIGH_Q + a1*b7*MED_V*HIGH_Q +
     a4*b7*LOW_W*MED_V*HIGH_Q + a5*b7*MED_Z*MED_V*HIGH_Q +
     a7*b7*LOW_W*MED_Z*MED_V*HIGH_Q;
    IMMMH = a1*b1 + a4*b1*MED_W + a5*b1*MED_Z + a7*b1*MED_W*MED_Z +
     a1*b4*MED_V + a4*b4*MED_W*MED_V + a5*b4*MED_Z*MED_V +
     a7*b4*MED_W*MED_Z*MED_V + a1*b5*HIGH_Q + a4*b5*MED_W*HIGH_Q +
     a5*b5*MED_Z*HIGH_Q + a7*b5*MED_W*MED_Z*HIGH_Q + a1*b7*MED_V*HIGH_Q +
     a4*b7*MED_W*MED_V*HIGH_Q + a5*b7*MED_Z*MED_V*HIGH_Q +
     a7*b7*MED_W*MED_Z*MED_V*HIGH_Q;
    IHMMH = a1*b1 + a4*b1*HIGH_W + a5*b1*MED_Z + a7*b1*HIGH_W*MED_Z +
     a1*b4*MED_V + a4*b4*HIGH_W*MED_V + a5*b4*MED_Z*MED_V +
     a7*b4*HIGH_W*MED_Z*MED_V + a1*b5*HIGH_Q + a4*b5*HIGH_W*HIGH_Q +
     a5*b5*MED_Z*HIGH_Q + a7*b5*HIGH_W*MED_Z*HIGH_Q + a1*b7*MED_V*HIGH_Q +
     a4*b7*HIGH_W*MED_V*HIGH_Q + a5*b7*MED_Z*MED_V*HIGH_Q +
     a7*b7*HIGH_W*MED_Z*MED_V*HIGH_Q;

    ILHMH = a1*b1 + a4*b1*LOW_W + a5*b1*HIGH_Z + a7*b1*LOW_W*HIGH_Z +
     a1*b4*MED_V + a4*b4*LOW_W*MED_V + a5*b4*HIGH_Z*MED_V +
     a7*b4*LOW_W*HIGH_Z*MED_V + a1*b5*HIGH_Q + a4*b5*LOW_W*HIGH_Q +
     a5*b5*HIGH_Z*HIGH_Q + a7*b5*LOW_W*HIGH_Z*HIGH_Q + a1*b7*MED_V*HIGH_Q +
     a4*b7*LOW_W*MED_V*HIGH_Q + a5*b7*HIGH_Z*MED_V*HIGH_Q +
     a7*b7*LOW_W*HIGH_Z*MED_V*HIGH_Q;
    IMHMH = a1*b1 + a4*b1*MED_W + a5*b1*HIGH_Z + a7*b1*MED_W*HIGH_Z +
     a1*b4*MED_V + a4*b4*MED_W*MED_V + a5*b4*HIGH_Z*MED_V +
     a7*b4*MED_W*HIGH_Z*MED_V + a1*b5*HIGH_Q + a4*b5*MED_W*HIGH_Q +
     a5*b5*HIGH_Z*HIGH_Q + a7*b5*MED_W*HIGH_Z*HIGH_Q + a1*b7*MED_V*HIGH_Q +
     a4*b7*MED_W*MED_V*HIGH_Q + a5*b7*HIGH_Z*MED_V*HIGH_Q +
     a7*b7*MED_W*HIGH_Z*MED_V*HIGH_Q;
    IHHMH = a1*b1 + a4*b1*HIGH_W + a5*b1*HIGH_Z + a7*b1*HIGH_W*HIGH_Z +
     a1*b4*MED_V + a4*b4*HIGH_W*MED_V + a5*b4*HIGH_Z*MED_V +
     a7*b4*HIGH_W*HIGH_Z*MED_V + a1*b5*HIGH_Q + a4*b5*HIGH_W*HIGH_Q +
     a5*b5*HIGH_Z*HIGH_Q + a7*b5*HIGH_W*HIGH_Z*HIGH_Q + a1*b7*MED_V*HIGH_Q +
     a4*b7*HIGH_W*MED_V*HIGH_Q + a5*b7*HIGH_Z*MED_V*HIGH_Q +
     a7*b7*HIGH_W*HIGH_Z*MED_V*HIGH_Q;

    ILLHH = a1*b1 + a4*b1*LOW_W + a5*b1*LOW_Z + a7*b1*LOW_W*LOW_Z +
     a1*b4*HIGH_V + a4*b4*LOW_W*HIGH_V + a5*b4*LOW_Z*HIGH_V +
     a7*b4*LOW_W*LOW_Z*HIGH_V + a1*b5*HIGH_Q + a4*b5*LOW_W*HIGH_Q +
     a5*b5*LOW_Z*HIGH_Q + a7*b5*LOW_W*LOW_Z*HIGH_Q + a1*b7*HIGH_V*HIGH_Q +
     a4*b7*LOW_W*HIGH_V*HIGH_Q + a5*b7*LOW_Z*HIGH_V*HIGH_Q +
     a7*b7*LOW_W*LOW_Z*HIGH_V*HIGH_Q;
    IMLHH = a1*b1 + a4*b1*MED_W + a5*b1*LOW_Z + a7*b1*MED_W*LOW_Z +
     a1*b4*HIGH_V + a4*b4*MED_W*HIGH_V + a5*b4*LOW_Z*HIGH_V +
     a7*b4*MED_W*LOW_Z*HIGH_V + a1*b5*HIGH_Q + a4*b5*MED_W*HIGH_Q +
     a5*b5*LOW_Z*HIGH_Q + a7*b5*MED_W*LOW_Z*HIGH_Q + a1*b7*HIGH_V*HIGH_Q +
     a4*b7*MED_W*HIGH_V*HIGH_Q + a5*b7*LOW_Z*HIGH_V*HIGH_Q +
     a7*b7*MED_W*LOW_Z*HIGH_V*HIGH_Q;
    IHLHH = a1*b1 + a4*b1*HIGH_W + a5*b1*LOW_Z + a7*b1*HIGH_W*LOW_Z +
     a1*b4*HIGH_V + a4*b4*HIGH_W*HIGH_V + a5*b4*LOW_Z*HIGH_V +
     a7*b4*HIGH_W*LOW_Z*HIGH_V + a1*b5*HIGH_Q + a4*b5*HIGH_W*HIGH_Q +
     a5*b5*LOW_Z*HIGH_Q + a7*b5*HIGH_W*LOW_Z*HIGH_Q + a1*b7*HIGH_V*HIGH_Q +
     a4*b7*HIGH_W*HIGH_V*HIGH_Q + a5*b7*LOW_Z*HIGH_V*HIGH_Q +
     a7*b7*HIGH_W*LOW_Z*HIGH_V*HIGH_Q;

    ILMHH = a1*b1 + a4*b1*LOW_W + a5*b1*MED_Z + a7*b1*LOW_W*MED_Z +
     a1*b4*HIGH_V + a4*b4*LOW_W*HIGH_V + a5*b4*MED_Z*HIGH_V +
     a7*b4*LOW_W*MED_Z*HIGH_V + a1*b5*HIGH_Q + a4*b5*LOW_W*HIGH_Q +
     a5*b5*MED_Z*HIGH_Q + a7*b5*LOW_W*MED_Z*HIGH_Q + a1*b7*HIGH_V*HIGH_Q +
     a4*b7*LOW_W*HIGH_V*HIGH_Q + a5*b7*MED_Z*HIGH_V*HIGH_Q +
     a7*b7*LOW_W*MED_Z*HIGH_V*HIGH_Q;
    IMMHH = a1*b1 + a4*b1*MED_W + a5*b1*MED_Z + a7*b1*MED_W*MED_Z +
     a1*b4*HIGH_V + a4*b4*MED_W*HIGH_V + a5*b4*MED_Z*HIGH_V +
     a7*b4*MED_W*MED_Z*HIGH_V + a1*b5*HIGH_Q + a4*b5*MED_W*HIGH_Q +
     a5*b5*MED_Z*HIGH_Q + a7*b5*MED_W*MED_Z*HIGH_Q + a1*b7*HIGH_V*HIGH_Q +
     a4*b7*MED_W*HIGH_V*HIGH_Q + a5*b7*MED_Z*HIGH_V*HIGH_Q +
     a7*b7*MED_W*MED_Z*HIGH_V*HIGH_Q;
    IHMHH = a1*b1 + a4*b1*HIGH_W + a5*b1*MED_Z + a7*b1*HIGH_W*MED_Z +
     a1*b4*HIGH_V + a4*b4*HIGH_W*HIGH_V + a5*b4*MED_Z*HIGH_V +
     a7*b4*HIGH_W*MED_Z*HIGH_V + a1*b5*HIGH_Q + a4*b5*HIGH_W*HIGH_Q +
     a5*b5*MED_Z*HIGH_Q + a7*b5*HIGH_W*MED_Z*HIGH_Q + a1*b7*HIGH_V*HIGH_Q +
     a4*b7*HIGH_W*HIGH_V*HIGH_Q + a5*b7*MED_Z*HIGH_V*HIGH_Q +
     a7*b7*HIGH_W*MED_Z*HIGH_V*HIGH_Q;

    ILHHH = a1*b1 + a4*b1*LOW_W + a5*b1*HIGH_Z + a7*b1*LOW_W*HIGH_Z +
     a1*b4*HIGH_V + a4*b4*LOW_W*HIGH_V + a5*b4*HIGH_Z*HIGH_V +
     a7*b4*LOW_W*HIGH_Z*HIGH_V + a1*b5*HIGH_Q + a4*b5*LOW_W*HIGH_Q +
     a5*b5*HIGH_Z*HIGH_Q + a7*b5*LOW_W*HIGH_Z*HIGH_Q + a1*b7*HIGH_V*HIGH_Q +
     a4*b7*LOW_W*HIGH_V*HIGH_Q + a5*b7*HIGH_Z*HIGH_V*HIGH_Q +
     a7*b7*LOW_W*HIGH_Z*HIGH_V*HIGH_Q;
    IMHHH = a1*b1 + a4*b1*MED_W + a5*b1*HIGH_Z + a7*b1*MED_W*HIGH_Z +
     a1*b4*HIGH_V + a4*b4*MED_W*HIGH_V + a5*b4*HIGH_Z*HIGH_V +
     a7*b4*MED_W*HIGH_Z*HIGH_V + a1*b5*HIGH_Q + a4*b5*MED_W*HIGH_Q +
     a5*b5*HIGH_Z*HIGH_Q + a7*b5*MED_W*HIGH_Z*HIGH_Q + a1*b7*HIGH_V*HIGH_Q +
     a4*b7*MED_W*HIGH_V*HIGH_Q + a5*b7*HIGH_Z*HIGH_V*HIGH_Q +
     a7*b7*MED_W*HIGH_Z*HIGH_V*HIGH_Q;
    IHHHH = a1*b1 + a4*b1*HIGH_W + a5*b1*HIGH_Z + a7*b1*HIGH_W*HIGH_Z +
     a1*b4*HIGH_V + a4*b4*HIGH_W*HIGH_V + a5*b4*HIGH_Z*HIGH_V +
     a7*b4*HIGH_W*HIGH_Z*HIGH_V + a1*b5*HIGH_Q + a4*b5*HIGH_W*HIGH_Q +
     a5*b5*HIGH_Z*HIGH_Q + a7*b5*HIGH_W*HIGH_Z*HIGH_Q + a1*b7*HIGH_V*HIGH_Q +
     a4*b7*HIGH_W*HIGH_V*HIGH_Q + a5*b7*HIGH_Z*HIGH_V*HIGH_Q +
     a7*b7*HIGH_W*HIGH_Z*HIGH_V*HIGH_Q;

! Calc conditional direct effects for each combination of moderator values

    DLOW_LOZ = cdash1 + cdash4*LOW_W + cdash5*LOW_Z + cdash7*LOW_W*LOW_Z;
    DMEW_LOZ = cdash1 + cdash4*MED_W + cdash5*LOW_Z + cdash7*MED_W*LOW_Z;
    DHIW_LOZ = cdash1 + cdash4*HIGH_W + cdash5*LOW_Z + cdash7*HIGH_W*LOW_Z;

    DLOW_MEZ = cdash1 + cdash4*LOW_W + cdash5*MED_Z + cdash7*LOW_W*MED_Z;
    DMEW_MEZ = cdash1 + cdash4*MED_W + cdash5*MED_Z + cdash7*MED_W*MED_Z;
    DHIW_MEZ = cdash1 + cdash4*HIGH_W + cdash5*MED_Z + cdash7*HIGH_W*MED_Z;

    DLOW_HIZ = cdash1 + cdash4*LOW_W + cdash5*HIGH_Z + cdash7*LOW_W*HIGH_Z;
    DMEW_HIZ = cdash1 + cdash4*MED_W + cdash5*HIGH_Z + cdash7*MED_W*HIGH_Z;
    DHIW_HIZ = cdash1 + cdash4*HIGH_W + cdash5*HIGH_Z + cdash7*HIGH_W*HIGH_Z;

! Calc conditional total effects for each combination of moderator values

    TLLLL = ILLLL + DLOW_LOZ;
    TMLLL = IMLLL + DMEW_LOZ;
    THLLL = IHLLL + DHIW_LOZ;

    TLMLL = ILMLL + DLOW_MEZ;
    TMMLL = IMMLL + DMEW_MEZ;
    THMLL = IHMLL + DHIW_MEZ;

    TLHLL = ILHLL + DLOW_HIZ;
    TMHLL = IMHLL + DMEW_HIZ;
    THHLL = IHHLL + DHIW_HIZ;

    TLLML = ILLML + DLOW_LOZ;
    TMLML = IMLML + DMEW_LOZ;
    THLML = IHLML + DHIW_LOZ;

    TLMML = ILMML + DLOW_MEZ;
    TMMML = IMMML + DMEW_MEZ;
    THMML = IHMML + DHIW_MEZ;

    TLHML = ILHML + DLOW_HIZ;
    TMHML = IMHML + DMEW_HIZ;
    THHML = IHHML + DHIW_HIZ;

    TLLHL = ILLHL + DLOW_LOZ;
    TMLHL = IMLHL + DMEW_LOZ;
    THLHL = IHLHL + DHIW_LOZ;

    TLMHL = ILMHL + DLOW_MEZ;
    TMMHL = IMMHL + DMEW_MEZ;
    THMHL = IHMHL + DHIW_MEZ;

    TLHHL = ILHHL + DLOW_HIZ;
    TMHHL = IMHHL + DMEW_HIZ;
    THHHL = IHHHL + DHIW_HIZ;

    TLLLM = ILLLM + DLOW_LOZ;
    TMLLM = IMLLM + DMEW_LOZ;
    THLLM = IHLLM + DHIW_LOZ;

    TLMLM = ILMLM + DLOW_MEZ;
    TMMLM = IMMLM + DMEW_MEZ;
    THMLM = IHMLM + DHIW_MEZ;

    TLHLM = ILHLM + DLOW_HIZ;
    TMHLM = IMHLM + DMEW_HIZ;
    THHLM = IHHLM + DHIW_HIZ;

    TLLMM = ILLMM + DLOW_LOZ;
    TMLMM = IMLMM + DMEW_LOZ;
    THLMM = IHLMM + DHIW_LOZ;

    TLMMM = ILMMM + DLOW_MEZ;
    TMMMM = IMMMM + DMEW_MEZ;
    THMMM = IHMMM + DHIW_MEZ;

    TLHMM = ILHMM + DLOW_HIZ;
    TMHMM = IMHMM + DMEW_HIZ;
    THHMM = IHHMM + DHIW_HIZ;

    TLLHM = ILLHM + DLOW_LOZ;
    TMLHM = IMLHM + DMEW_LOZ;
    THLHM = IHLHM + DHIW_LOZ;

    TLMHM = ILMHM + DLOW_MEZ;
    TMMHM = IMMHM + DMEW_MEZ;
    THMHM = IHMHM + DHIW_MEZ;

    TLHHM = ILHHM + DLOW_HIZ;
    TMHHM = IMHHM + DMEW_HIZ;
    THHHM = IHHHM + DHIW_HIZ;

    TLLLH = ILLLH + DLOW_LOZ;
    TMLLH = IMLLH + DMEW_LOZ;
    THLLH = IHLLH + DHIW_LOZ;

    TLMLH = ILMLH + DLOW_MEZ;
    TMMLH = IMMLH + DMEW_MEZ;
    THMLH = IHMLH + DHIW_MEZ;

    TLHLH = ILHLH + DLOW_HIZ;
    TMHLH = IMHLH + DMEW_HIZ;
    THHLH = IHHLH + DHIW_HIZ;

    TLLMH = ILLMH + DLOW_LOZ;
    TMLMH = IMLMH + DMEW_LOZ;
    THLMH = IHLMH + DHIW_LOZ;

    TLMMH = ILMMH + DLOW_MEZ;
    TMMMH = IMMMH + DMEW_MEZ;
    THMMH = IHMMH + DHIW_MEZ;

    TLHMH = ILHMH + DLOW_HIZ;
    TMHMH = IMHMH + DMEW_HIZ;
    THHMH = IHHMH + DHIW_HIZ;

    TLLHH = ILLHH + DLOW_LOZ;
    TMLHH = IMLHH + DMEW_LOZ;
    THLHH = IHLHH + DHIW_LOZ;

    TLMHH = ILMHH + DLOW_MEZ;
    TMMHH = IMMHH + DMEW_MEZ;
    THMHH = IHMHH + DHIW_MEZ;

    TLHHH = ILHHH + DLOW_HIZ;
    TMHHH = IMHHH + DMEW_HIZ;
    THHHH = IHHHH + DHIW_HIZ;

! 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 from -3 to 3 in LOOP() statement since
! X is factor with mean set at default of 0

    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,-3,3,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;

 

Return to Model Template index.

To cite this page and/or any code used, please use:
Stride C.B., Gardner S., Catley. N. & Thomas, F.(2015) 'Mplus code for the mediation, moderation, and moderated mediation model templates from Andrew Hayes' PROCESS analysis examples' , http://www.figureitout.org.uk

Home
Statistical Consultancy
Data Management
Public Training Courses
Inhouse & Bespoke Training
Links & Resources
About Us & Contact Details