来自图书《MPlus中介调节模型》
模型方程:
Y = b0 + b1M1 + b2M2 + b3W + b4M1W + b5M2W + c'X
M1 = a01 + a1X
M2 = a02 + a2X + d1M1
代入化简:
Y = b0 + b1(a01 + a1X) + b2(a02 + a2X + d1(a01 + a1X)) + b3W + b4(a01 + a1X)W + b5(a02 + a2X + d1(a01 + a1X))W + c'X
Y = b0 + a01b1 + a1b1X + a02b2 + a2b2X + a01d1b2 + a1d1b2X + b3W + a01b4W + a1b4XW + a02b5 + a2b5X + a01d1b5W + a1d1b5XW + c'X
模型方程:
Y = b0 + b1M1 + b2M2 + b3W + b4M1W + b5M2W + c'X
M1 = a01 + a1X
M2 = a02 + a2X + d1M1
代入化简:
Y = b0 + b1(a01 + a1X) + b2(a02 + a2X + d1(a01 + a1X)) + b3W + b4(a01 + a1X)W + b5(a02 + a2X + d1(a01 + a1X))W + c'X
Y = b0 + a01b1 + a1b1X + a02b2 + a2b2X + a01d1b2 + a1d1b2X + b3W + a01b4W + a1b4XW + a02b5 + a2b5X + a01d1b5W + a1d1b5XW + c'X
整理:
Y = (b0 + a01b1 + a02b2 + a01d1b2 + b3W + a01b4W + a02b5 + a01d1b5W) + (a1b1 + a2b2 + a2b5W + a1d1b2 + a1b4W + a1d1b5W + c')X
模型方程:
Y = b0 + b1M1 + b2M2 + b3W + b4M1W + b5M2W + c'X
M1 = a01 + a1X
M2 = a02 + a2X + d1M1
代入化简:
Y = b0 + b1(a01 + a1X) + b2(a02 + a2X + d1(a01 + a1X)) + b3W + b4(a01 + a1X)W + b5(a02 + a2X + d1(a01 + a1X))W + c'X
Y = b0 + a01b1 + a1b1X + a02b2 + a2b2X + a01d1b2 + a1d1b2X + b3W + a01b4W + a1b4XW + a02b5 + a2b5X + a01d1b5W + a1d1b5XW + c'X
整理:
Y = (b0 + a01b1 + a02b2 + a01d1b2 + b3W + a01b4W + a02b5 + a01d1b5W) + (a1b1 + a2b2 + a2b5W + a1d1b2 + a1b4W + a1d1b5W + c')X
结果:
间接效应 (conditional on W):
* a1(b1 + b4W)
* a2(b2 + b5W)
* a1d1(b2 + b5W)
直接效应:
* c'
! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y M1W M2W;
! Create interaction term
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:
M1W = M1*W;
M2W = M2*W;
ANALYSIS:
TYPE = GENERAL;
ESTIMATOR = ML;
BOOTSTRAP = 10000;
! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y M1W M2W;
! Create interaction term
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:
M1W = M1*W;
M2W = M2*W;
ANALYSIS:
TYPE = GENERAL;
ESTIMATOR = ML;
BOOTSTRAP = 10000;
! In model statement name each path using parentheses
MODEL:
! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y M1W M2W;
! Create interaction term
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:
M1W = M1*W;
M2W = M2*W;
ANALYSIS:
TYPE = GENERAL;
ESTIMATOR = ML;
BOOTSTRAP = 10000;
! In model statement name each path using parentheses
MODEL:
Y ON M1 (b1);
Y ON M2 (b2);
Y ON W (b3);
Y ON M1W (b4);
Y ON M2W (b5);
Y ON X (cdash);
! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y M1W M2W;
! Create interaction term
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:
M1W = M1*W;
M2W = M2*W;
ANALYSIS:
TYPE = GENERAL;
ESTIMATOR = ML;
BOOTSTRAP = 10000;
! In model statement name each path using parentheses
MODEL:
Y ON M1 (b1);
Y ON M2 (b2);
Y ON W (b3);
Y ON M1W (b4);
Y ON M2W (b5);
Y ON X (cdash);
! direct effect of X on Y
M1 ON X (a1);
M2 ON X (a2);
M2 ON M1 (d1);
! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y M1W M2W;
! Create interaction term
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:
M1W = M1*W;
M2W = M2*W;
ANALYSIS:
TYPE = GENERAL;
ESTIMATOR = ML;
BOOTSTRAP = 10000;
! In model statement name each path using parentheses
MODEL:
Y ON M1 (b1);
Y ON M2 (b2);
Y ON W (b3);
Y ON M1W (b4);
Y ON M2W (b5);
Y ON X (cdash);
! direct effect of X on Y
M1 ON X (a1);
M2 ON X (a2);
M2 ON M1 (d1);
! Use model constraint subcommand to test simple slopes
! You need to pick low, medium and high moderator values,
! for example, of 1 SD below mean, mean, 1 SD above mean
! Also calc total effects at lo, med, hi values of moderator
! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y M1W M2W;
! Create interaction term
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:
M1W = M1*W;
M2W = M2*W;
ANALYSIS:
TYPE = GENERAL;
ESTIMATOR = ML;
BOOTSTRAP = 10000;
! In model statement name each path using parentheses
MODEL:
Y ON M1 (b1);
Y ON M2 (b2);
Y ON W (b3);
Y ON M1W (b4);
Y ON M2W (b5);
Y ON X (cdash);
! direct effect of X on Y
M1 ON X (a1);
M2 ON X (a2);
M2 ON M1 (d1);
! Use model constraint subcommand to test simple slopes
! You need to pick low, medium and high moderator values,
! for example, of 1 SD below mean, mean, 1 SD above mean
! Also calc total effects at lo, med, hi values of moderator
MODEL CONSTRAINT:
NEW(LOW_W MED_W HIGH_W
LWa1b1 MWa1b1 HWa1b1
LWa2b2 MWa2b2 HWa2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM_A IMM_B IMM_C
TOT_LOWW TOT_MEDW TOT_HIW);
! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y M1W M2W;
! Create interaction term
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:
M1W = M1*W;
M2W = M2*W;
ANALYSIS:
TYPE = GENERAL;
ESTIMATOR = ML;
BOOTSTRAP = 10000;
! In model statement name each path using parentheses
MODEL:
Y ON M1 (b1);
Y ON M2 (b2);
Y ON W (b3);
Y ON M1W (b4);
Y ON M2W (b5);
Y ON X (cdash);
! direct effect of X on Y
M1 ON X (a1);
M2 ON X (a2);
M2 ON M1 (d1);
! Use model constraint subcommand to test simple slopes
! You need to pick low, medium and high moderator values,
! for example, of 1 SD below mean, mean, 1 SD above mean
! Also calc total effects at lo, med, hi values of moderator
MODEL CONSTRAINT:
NEW(LOW_W MED_W HIGH_W
LWa1b1 MWa1b1 HWa1b1
LWa2b2 MWa2b2 HWa2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM_A IMM_B IMM_C
TOT_LOWW TOT_MEDW TOT_HIW);
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
! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y M1W M2W;
! Create interaction term
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:
M1W = M1*W;
M2W = M2*W;
ANALYSIS:
TYPE = GENERAL;
ESTIMATOR = ML;
BOOTSTRAP = 10000;
! In model statement name each path using parentheses
MODEL:
Y ON M1 (b1);
Y ON M2 (b2);
Y ON W (b3);
Y ON M1W (b4);
Y ON M2W (b5);
Y ON X (cdash);
! direct effect of X on Y
M1 ON X (a1);
M2 ON X (a2);
M2 ON M1 (d1);
! Use model constraint subcommand to test simple slopes
! You need to pick low, medium and high moderator values,
! for example, of 1 SD below mean, mean, 1 SD above mean
! Also calc total effects at lo, med, hi values of moderator
MODEL CONSTRAINT:
NEW(LOW_W MED_W HIGH_W
LWa1b1 MWa1b1 HWa1b1
LWa2b2 MWa2b2 HWa2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM_A IMM_B IMM_C
TOT_LOWW TOT_MEDW TOT_HIW);
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
! Now calc indirect and total effects for each value of W
! Conditional indirect effects of X on Y via M1 only given values of W
LWa1b1 = a1*b1 + a1*b4*LOW_W;
MWa1b1 = a1*b1 + a1*b4*MED_W;
HWa1b1 = a1*b1 + a1*b4*HIGH_W;
! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y M1W M2W;
! Create interaction term
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:
M1W = M1*W;
M2W = M2*W;
ANALYSIS:
TYPE = GENERAL;
ESTIMATOR = ML;
BOOTSTRAP = 10000;
! In model statement name each path using parentheses
MODEL:
Y ON M1 (b1);
Y ON M2 (b2);
Y ON W (b3);
Y ON M1W (b4);
Y ON M2W (b5);
Y ON X (cdash);
! direct effect of X on Y
M1 ON X (a1);
M2 ON X (a2);
M2 ON M1 (d1);
! Use model constraint subcommand to test simple slopes
! You need to pick low, medium and high moderator values,
! for example, of 1 SD below mean, mean, 1 SD above mean
! Also calc total effects at lo, med, hi values of moderator
MODEL CONSTRAINT:
NEW(LOW_W MED_W HIGH_W
LWa1b1 MWa1b1 HWa1b1
LWa2b2 MWa2b2 HWa2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM_A IMM_B IMM_C
TOT_LOWW TOT_MEDW TOT_HIW);
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
! Now calc indirect and total effects for each value of W
! Conditional indirect effects of X on Y via M1 only given values of W
LWa1b1 = a1*b1 + a1*b4*LOW_W;
MWa1b1 = a1*b1 + a1*b4*MED_W;
HWa1b1 = a1*b1 + a1*b4*HIGH_W;
! Conditional indirect effects of X on Y via M2 only given values of W
LWa2b2 = a2*b2 + a2*b5*LOW_W;
MWa2b2 = a2*b2 + a2*b5*MED_W;
HWa2b2 = a2*b2 + a2*b5*HIGH_W;
! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y M1W M2W;
! Create interaction term
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:
M1W = M1*W;
M2W = M2*W;
ANALYSIS:
TYPE = GENERAL;
ESTIMATOR = ML;
BOOTSTRAP = 10000;
! In model statement name each path using parentheses
MODEL:
Y ON M1 (b1);
Y ON M2 (b2);
Y ON W (b3);
Y ON M1W (b4);
Y ON M2W (b5);
Y ON X (cdash);
! direct effect of X on Y
M1 ON X (a1);
M2 ON X (a2);
M2 ON M1 (d1);
! Use model constraint subcommand to test simple slopes
! You need to pick low, medium and high moderator values,
! for example, of 1 SD below mean, mean, 1 SD above mean
! Also calc total effects at lo, med, hi values of moderator
MODEL CONSTRAINT:
NEW(LOW_W MED_W HIGH_W
LWa1b1 MWa1b1 HWa1b1
LWa2b2 MWa2b2 HWa2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM_A IMM_B IMM_C
TOT_LOWW TOT_MEDW TOT_HIW);
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
! Now calc indirect and total effects for each value of W
! Conditional indirect effects of X on Y via M1 only given values of W
LWa1b1 = a1*b1 + a1*b4*LOW_W;
MWa1b1 = a1*b1 + a1*b4*MED_W;
HWa1b1 = a1*b1 + a1*b4*HIGH_W;
! Conditional indirect effects of X on Y via M2 only given values of W
LWa2b2 = a2*b2 + a2*b5*LOW_W;
MWa2b2 = a2*b2 + a2*b5*MED_W;
HWa2b2 = a2*b2 + a2*b5*HIGH_W;
! Conditional indirect effects of X on Y via M1 and M2 given values of W
LWa1d1b2 = a1*d1*b2 + a1*d1*b5*LOW_W;
MWa1d1b2 = a1*d1*b2 + a1*d1*b5*MED_W;
HWa1d1b2 = a1*d1*b2 + a1*d1*b5*HIGH_W;
! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y M1W M2W;
! Create interaction term
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:
M1W = M1*W;
M2W = M2*W;
ANALYSIS:
TYPE = GENERAL;
ESTIMATOR = ML;
BOOTSTRAP = 10000;
! In model statement name each path using parentheses
MODEL:
Y ON M1 (b1);
Y ON M2 (b2);
Y ON W (b3);
Y ON M1W (b4);
Y ON M2W (b5);
Y ON X (cdash);
! direct effect of X on Y
M1 ON X (a1);
M2 ON X (a2);
M2 ON M1 (d1);
! Use model constraint subcommand to test simple slopes
! You need to pick low, medium and high moderator values,
! for example, of 1 SD below mean, mean, 1 SD above mean
! Also calc total effects at lo, med, hi values of moderator
MODEL CONSTRAINT:
NEW(LOW_W MED_W HIGH_W
LWa1b1 MWa1b1 HWa1b1
LWa2b2 MWa2b2 HWa2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM_A IMM_B IMM_C
TOT_LOWW TOT_MEDW TOT_HIW);
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
! Now calc indirect and total effects for each value of W
! Conditional indirect effects of X on Y via M1 only given values of W
LWa1b1 = a1*b1 + a1*b4*LOW_W;
MWa1b1 = a1*b1 + a1*b4*MED_W;
HWa1b1 = a1*b1 + a1*b4*HIGH_W;
! Conditional indirect effects of X on Y via M2 only given values of W
LWa2b2 = a2*b2 + a2*b5*LOW_W;
MWa2b2 = a2*b2 + a2*b5*MED_W;
HWa2b2 = a2*b2 + a2*b5*HIGH_W;
! Conditional indirect effects of X on Y via M1 and M2 given values of W
LWa1d1b2 = a1*d1*b2 + a1*d1*b5*LOW_W;
MWa1d1b2 = a1*d1*b2 + a1*d1*b5*MED_W;
HWa1d1b2 = a1*d1*b2 + a1*d1*b5*HIGH_W;
! Indices of Moderated Mediation
IMM_A = a1*b4;
IMM_B = a1*d1*b5;
IMM_C = a2*b5;
! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y M1W M2W;
! Create interaction term
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:
M1W = M1*W;
M2W = M2*W;
ANALYSIS:
TYPE = GENERAL;
ESTIMATOR = ML;
BOOTSTRAP = 10000;
! In model statement name each path using parentheses
MODEL:
Y ON M1 (b1);
Y ON M2 (b2);
Y ON W (b3);
Y ON M1W (b4);
Y ON M2W (b5);
Y ON X (cdash);
! direct effect of X on Y
M1 ON X (a1);
M2 ON X (a2);
M2 ON M1 (d1);
! Use model constraint subcommand to test simple slopes
! You need to pick low, medium and high moderator values,
! for example, of 1 SD below mean, mean, 1 SD above mean
! Also calc total effects at lo, med, hi values of moderator
MODEL CONSTRAINT:
NEW(LOW_W MED_W HIGH_W
LWa1b1 MWa1b1 HWa1b1
LWa2b2 MWa2b2 HWa2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM_A IMM_B IMM_C
TOT_LOWW TOT_MEDW TOT_HIW);
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
! Now calc indirect and total effects for each value of W
! Conditional indirect effects of X on Y via M1 only given values of W
LWa1b1 = a1*b1 + a1*b4*LOW_W;
MWa1b1 = a1*b1 + a1*b4*MED_W;
HWa1b1 = a1*b1 + a1*b4*HIGH_W;
! Conditional indirect effects of X on Y via M2 only given values of W
LWa2b2 = a2*b2 + a2*b5*LOW_W;
MWa2b2 = a2*b2 + a2*b5*MED_W;
HWa2b2 = a2*b2 + a2*b5*HIGH_W;
! Conditional indirect effects of X on Y via M1 and M2 given values of W
LWa1d1b2 = a1*d1*b2 + a1*d1*b5*LOW_W;
MWa1d1b2 = a1*d1*b2 + a1*d1*b5*MED_W;
HWa1d1b2 = a1*d1*b2 + a1*d1*b5*HIGH_W;
! Indices of Moderated Mediation
IMM_A = a1*b4;
IMM_B = a1*d1*b5;
IMM_C = a2*b5;
! Conditional total effects of X on Y given values of W
TOT_LOWW = LWa1d1b2 + LWa2b2 + LWa1b1 + cdash;
TOT_MEDW = MWa1d1b2 + MWa2b2 + MWa1b1 + cdash ;
TOT_HIW = HWa1d1b2 + HWa2b2 + HWa1b1 + cdash;
! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y M1W M2W;
! Create interaction term
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:
M1W = M1*W;
M2W = M2*W;
ANALYSIS:
TYPE = GENERAL;
ESTIMATOR = ML;
BOOTSTRAP = 10000;
! In model statement name each path using parentheses
MODEL:
Y ON M1 (b1);
Y ON M2 (b2);
Y ON W (b3);
Y ON M1W (b4);
Y ON M2W (b5);
Y ON X (cdash);
! direct effect of X on Y
M1 ON X (a1);
M2 ON X (a2);
M2 ON M1 (d1);
! Use model constraint subcommand to test simple slopes
! You need to pick low, medium and high moderator values,
! for example, of 1 SD below mean, mean, 1 SD above mean
! Also calc total effects at lo, med, hi values of moderator
MODEL CONSTRAINT:
NEW(LOW_W MED_W HIGH_W
LWa1b1 MWa1b1 HWa1b1
LWa2b2 MWa2b2 HWa2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM_A IMM_B IMM_C
TOT_LOWW TOT_MEDW TOT_HIW);
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
! Now calc indirect and total effects for each value of W
! Conditional indirect effects of X on Y via M1 only given values of W
LWa1b1 = a1*b1 + a1*b4*LOW_W;
MWa1b1 = a1*b1 + a1*b4*MED_W;
HWa1b1 = a1*b1 + a1*b4*HIGH_W;
! Conditional indirect effects of X on Y via M2 only given values of W
LWa2b2 = a2*b2 + a2*b5*LOW_W;
MWa2b2 = a2*b2 + a2*b5*MED_W;
HWa2b2 = a2*b2 + a2*b5*HIGH_W;
! Conditional indirect effects of X on Y via M1 and M2 given values of W
LWa1d1b2 = a1*d1*b2 + a1*d1*b5*LOW_W;
MWa1d1b2 = a1*d1*b2 + a1*d1*b5*MED_W;
HWa1d1b2 = a1*d1*b2 + a1*d1*b5*HIGH_W;
! Indices of Moderated Mediation
IMM_A = a1*b4;
IMM_B = a1*d1*b5;
IMM_C = a2*b5;
! Conditional total effects of X on Y given values of W
TOT_LOWW = LWa1d1b2 + LWa2b2 + LWa1b1 + cdash;
TOT_MEDW = MWa1d1b2 + MWa2b2 + MWa1b1 + cdash ;
TOT_HIW = HWa1d1b2 + HWa2b2 + HWa1b1 + cdash;
! Use loop plot to plot total effect of X on Y for low, med, high values of W
! 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(LOMOD MEDMOD HIMOD);
! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y M1W M2W;
! Create interaction term
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:
M1W = M1*W;
M2W = M2*W;
ANALYSIS:
TYPE = GENERAL;
ESTIMATOR = ML;
BOOTSTRAP = 10000;
! In model statement name each path using parentheses
MODEL:
Y ON M1 (b1);
Y ON M2 (b2);
Y ON W (b3);
Y ON M1W (b4);
Y ON M2W (b5);
Y ON X (cdash);
! direct effect of X on Y
M1 ON X (a1);
M2 ON X (a2);
M2 ON M1 (d1);
! Use model constraint subcommand to test simple slopes
! You need to pick low, medium and high moderator values,
! for example, of 1 SD below mean, mean, 1 SD above mean
! Also calc total effects at lo, med, hi values of moderator
MODEL CONSTRAINT:
NEW(LOW_W MED_W HIGH_W
LWa1b1 MWa1b1 HWa1b1
LWa2b2 MWa2b2 HWa2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM_A IMM_B IMM_C
TOT_LOWW TOT_MEDW TOT_HIW);
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
! Now calc indirect and total effects for each value of W
! Conditional indirect effects of X on Y via M1 only given values of W
LWa1b1 = a1*b1 + a1*b4*LOW_W;
MWa1b1 = a1*b1 + a1*b4*MED_W;
HWa1b1 = a1*b1 + a1*b4*HIGH_W;
! Conditional indirect effects of X on Y via M2 only given values of W
LWa2b2 = a2*b2 + a2*b5*LOW_W;
MWa2b2 = a2*b2 + a2*b5*MED_W;
HWa2b2 = a2*b2 + a2*b5*HIGH_W;
! Conditional indirect effects of X on Y via M1 and M2 given values of W
LWa1d1b2 = a1*d1*b2 + a1*d1*b5*LOW_W;
MWa1d1b2 = a1*d1*b2 + a1*d1*b5*MED_W;
HWa1d1b2 = a1*d1*b2 + a1*d1*b5*HIGH_W;
! Indices of Moderated Mediation
IMM_A = a1*b4;
IMM_B = a1*d1*b5;
IMM_C = a2*b5;
! Conditional total effects of X on Y given values of W
TOT_LOWW = LWa1d1b2 + LWa2b2 + LWa1b1 + cdash;
TOT_MEDW = MWa1d1b2 + MWa2b2 + MWa1b1 + cdash ;
TOT_HIW = HWa1d1b2 + HWa2b2 + HWa1b1 + cdash;
! Use loop plot to plot total effect of X on Y for low, med, high values of W
! 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(LOMOD MEDMOD HIMOD);
LOOP(XVAL,1,5,0.1);
LOMOD = TOT_LOWW*XVAL;
MEDMOD = TOT_MEDW*XVAL;
HIMOD = TOT_HIW*XVAL;
! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y M1W M2W;
! Create interaction term
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:
M1W = M1*W;
M2W = M2*W;
ANALYSIS:
TYPE = GENERAL;
ESTIMATOR = ML;
BOOTSTRAP = 10000;
! In model statement name each path using parentheses
MODEL:
Y ON M1 (b1);
Y ON M2 (b2);
Y ON W (b3);
Y ON M1W (b4);
Y ON M2W (b5);
Y ON X (cdash);
! direct effect of X on Y
M1 ON X (a1);
M2 ON X (a2);
M2 ON M1 (d1);
! Use model constraint subcommand to test simple slopes
! You need to pick low, medium and high moderator values,
! for example, of 1 SD below mean, mean, 1 SD above mean
! Also calc total effects at lo, med, hi values of moderator
MODEL CONSTRAINT:
NEW(LOW_W MED_W HIGH_W
LWa1b1 MWa1b1 HWa1b1
LWa2b2 MWa2b2 HWa2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM_A IMM_B IMM_C
TOT_LOWW TOT_MEDW TOT_HIW);
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
! Now calc indirect and total effects for each value of W
! Conditional indirect effects of X on Y via M1 only given values of W
LWa1b1 = a1*b1 + a1*b4*LOW_W;
MWa1b1 = a1*b1 + a1*b4*MED_W;
HWa1b1 = a1*b1 + a1*b4*HIGH_W;
! Conditional indirect effects of X on Y via M2 only given values of W
LWa2b2 = a2*b2 + a2*b5*LOW_W;
MWa2b2 = a2*b2 + a2*b5*MED_W;
HWa2b2 = a2*b2 + a2*b5*HIGH_W;
! Conditional indirect effects of X on Y via M1 and M2 given values of W
LWa1d1b2 = a1*d1*b2 + a1*d1*b5*LOW_W;
MWa1d1b2 = a1*d1*b2 + a1*d1*b5*MED_W;
HWa1d1b2 = a1*d1*b2 + a1*d1*b5*HIGH_W;
! Indices of Moderated Mediation
IMM_A = a1*b4;
IMM_B = a1*d1*b5;
IMM_C = a2*b5;
! Conditional total effects of X on Y given values of W
TOT_LOWW = LWa1d1b2 + LWa2b2 + LWa1b1 + cdash;
TOT_MEDW = MWa1d1b2 + MWa2b2 + MWa1b1 + cdash ;
TOT_HIW = HWa1d1b2 + HWa2b2 + HWa1b1 + cdash;
! Use loop plot to plot total effect of X on Y for low, med, high values of W
! 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(LOMOD MEDMOD HIMOD);
LOOP(XVAL,1,5,0.1);
LOMOD = TOT_LOWW*XVAL;
MEDMOD = TOT_MEDW*XVAL;
HIMOD = TOT_HIW*XVAL;
PLOT:
TYPE = plot2;
! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y M1W M2W;
! Create interaction term
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:
M1W = M1*W;
M2W = M2*W;
ANALYSIS:
TYPE = GENERAL;
ESTIMATOR = ML;
BOOTSTRAP = 10000;
! In model statement name each path using parentheses
MODEL:
Y ON M1 (b1);
Y ON M2 (b2);
Y ON W (b3);
Y ON M1W (b4);
Y ON M2W (b5);
Y ON X (cdash);
! direct effect of X on Y
M1 ON X (a1);
M2 ON X (a2);
M2 ON M1 (d1);
! Use model constraint subcommand to test simple slopes
! You need to pick low, medium and high moderator values,
! for example, of 1 SD below mean, mean, 1 SD above mean
! Also calc total effects at lo, med, hi values of moderator
MODEL CONSTRAINT:
NEW(LOW_W MED_W HIGH_W
LWa1b1 MWa1b1 HWa1b1
LWa2b2 MWa2b2 HWa2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM_A IMM_B IMM_C
TOT_LOWW TOT_MEDW TOT_HIW);
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
! Now calc indirect and total effects for each value of W
! Conditional indirect effects of X on Y via M1 only given values of W
LWa1b1 = a1*b1 + a1*b4*LOW_W;
MWa1b1 = a1*b1 + a1*b4*MED_W;
HWa1b1 = a1*b1 + a1*b4*HIGH_W;
! Conditional indirect effects of X on Y via M2 only given values of W
LWa2b2 = a2*b2 + a2*b5*LOW_W;
MWa2b2 = a2*b2 + a2*b5*MED_W;
HWa2b2 = a2*b2 + a2*b5*HIGH_W;
! Conditional indirect effects of X on Y via M1 and M2 given values of W
LWa1d1b2 = a1*d1*b2 + a1*d1*b5*LOW_W;
MWa1d1b2 = a1*d1*b2 + a1*d1*b5*MED_W;
HWa1d1b2 = a1*d1*b2 + a1*d1*b5*HIGH_W;
! Indices of Moderated Mediation
IMM_A = a1*b4;
IMM_B = a1*d1*b5;
IMM_C = a2*b5;
! Conditional total effects of X on Y given values of W
TOT_LOWW = LWa1d1b2 + LWa2b2 + LWa1b1 + cdash;
TOT_MEDW = MWa1d1b2 + MWa2b2 + MWa1b1 + cdash ;
TOT_HIW = HWa1d1b2 + HWa2b2 + HWa1b1 + cdash;
! Use loop plot to plot total effect of X on Y for low, med, high values of W
! 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(LOMOD MEDMOD HIMOD);
LOOP(XVAL,1,5,0.1);
LOMOD = TOT_LOWW*XVAL;
MEDMOD = TOT_MEDW*XVAL;
HIMOD = TOT_HIW*XVAL;
PLOT:
TYPE = plot2;
OUTPUT:
STAND CINT(bcbootstrap);