来自图书《MPlus中介调节模型》
模型方程:
Y = b_0 + b_1M_1 + b_2M_2 + c'X
M_1 = a_{01} + a_1X
M_2 = a_{02} + a_2X + d_1M_1 + d_2W + d_3M_1W
代入和展开:
Y = b_0 + b_1(a_{01} + a_1X) + b_2(a_{02} + a_2X + d_1(a_{01} + a_1X) + d_2W + d_3(a_{01} + a_1X)W) + c'X
Y = b_0 + a_{01}b_1 + a_1b_1X + a_{02}b_2 + a_2b_2X + a_{01}d_1b_2 + a_1d_1b_2X + d_2b_2W + a_{01}d_3b_2W + a_1d_3b_2XW + c'X
模型方程:
Y = b_0 + b_1M_1 + b_2M_2 + c'X
M_1 = a_{01} + a_1X
M_2 = a_{02} + a_2X + d_1M_1 + d_2W + d_3M_1W
代入和展开:
Y = b_0 + b_1(a_{01} + a_1X) + b_2(a_{02} + a_2X + d_1(a_{01} + a_1X) + d_2W + d_3(a_{01} + a_1X)W) + c'X
Y = b_0 + a_{01}b_1 + a_1b_1X + a_{02}b_2 + a_2b_2X + a_{01}d_1b_2 + a_1d_1b_2X + d_2b_2W + a_{01}d_3b_2W + a_1d_3b_2XW + c'X
整理成 Y = a + bX 的形式:
Y = (b_0 + a_{01}b_1 + a_{02}b_2 + a_{01}d_1b_2 + d_2b_2W + a_{01}d_3b_2W) + (a_1b_1 + a_1d_1b_2 + a_2b_2 + a_1d_3b_2W + c')X
模型方程:
Y = b_0 + b_1M_1 + b_2M_2 + c'X
M_1 = a_{01} + a_1X
M_2 = a_{02} + a_2X + d_1M_1 + d_2W + d_3M_1W
代入和展开:
Y = b_0 + b_1(a_{01} + a_1X) + b_2(a_{02} + a_2X + d_1(a_{01} + a_1X) + d_2W + d_3(a_{01} + a_1X)W) + c'X
Y = b_0 + a_{01}b_1 + a_1b_1X + a_{02}b_2 + a_2b_2X + a_{01}d_1b_2 + a_1d_1b_2X + d_2b_2W + a_{01}d_3b_2W + a_1d_3b_2XW + c'X
整理成 Y = a + bX 的形式:
Y = (b_0 + a_{01}b_1 + a_{02}b_2 + a_{01}d_1b_2 + d_2b_2W + a_{01}d_3b_2W) + (a_1b_1 + a_1d_1b_2 + a_2b_2 + a_1d_3b_2W + c')X
提取效应:
X对Y的三个间接效应:
a_1b_1 (X -> M_1 -> Y)
a_2b_2 (X -> M_2 -> Y)
a_1b_2(d_1 + d_3W) (X -> M_1 -> M_2 -> Y, 受W调节)
X对Y的直接效应: c'
! Predictor variable - X
! Mediator variable(s) – M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y M1W;
! Create interaction term
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:
M1W = M1*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;
! Create interaction term
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:
M1W = M1*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 X (cdash);
! direct effect of X on Y
M1 ON X (a1);
M2 ON X (a2);
M2 ON M1 (d1);
M2 ON W (d2);
M2 ON M1W (d3);
! Predictor variable - X
! Mediator variable(s) – M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y M1W;
! Create interaction term
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:
M1W = M1*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 X (cdash);
! direct effect of X on Y
M1 ON X (a1);
M2 ON X (a2);
M2 ON M1 (d1);
M2 ON W (d2);
M2 ON M1W (d3);
! 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
a1b1 a2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM
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;
! Create interaction term
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:
M1W = M1*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 X (cdash);
! direct effect of X on Y
M1 ON X (a1);
M2 ON X (a2);
M2 ON M1 (d1);
M2 ON W (d2);
M2 ON M1W (d3);
! 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
a1b1 a2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM
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
a1b1 = a1*b1;
! Specific indirect effect of X on Y via M1 only
a2b2 = a2*b2;
! Specific indirect effect of X on Y via M2 only
! Predictor variable - X
! Mediator variable(s) – M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y M1W;
! Create interaction term
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:
M1W = M1*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 X (cdash);
! direct effect of X on Y
M1 ON X (a1);
M2 ON X (a2);
M2 ON M1 (d1);
M2 ON W (d2);
M2 ON M1W (d3);
! 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
a1b1 a2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM
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
a1b1 = a1*b1;
! Specific indirect effect of X on Y via M1 only
a2b2 = a2*b2;
! Specific indirect effect of X on Y via M2 only
! Conditional indirect effects of X on Y via M1 and M2 given values of W
LWa1d1b2 = a1*d1*b2 + a1*d3*b2*LOW_W;
MWa1d1b2 = a1*d1*b2 + a1*d3*b2*MED_W;
HWa1d1b2 = a1*d1*b2 + a1*d3*b2*HIGH_W;
! Index of Moderated Mediation
IMM = a1*d3*b2;
! Predictor variable - X
! Mediator variable(s) – M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y M1W;
! Create interaction term
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:
M1W = M1*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 X (cdash);
! direct effect of X on Y
M1 ON X (a1);
M2 ON X (a2);
M2 ON M1 (d1);
M2 ON W (d2);
M2 ON M1W (d3);
! 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
a1b1 a2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM
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
a1b1 = a1*b1;
! Specific indirect effect of X on Y via M1 only
a2b2 = a2*b2;
! Specific indirect effect of X on Y via M2 only
! Conditional indirect effects of X on Y via M1 and M2 given values of W
LWa1d1b2 = a1*d1*b2 + a1*d3*b2*LOW_W;
MWa1d1b2 = a1*d1*b2 + a1*d3*b2*MED_W;
HWa1d1b2 = a1*d1*b2 + a1*d3*b2*HIGH_W;
! Index of Moderated Mediation
IMM = a1*d3*b2;
! Conditional total effects of X on Y given values of W
TOT_LOWW = LWa1d1b2 + a1b1 + a2b2 + cdash;
TOT_MEDW = MWa1d1b2 + a1b1 + a2b2 + cdash ;
TOT_HIW = HWa1d1b2 + a1b1 + a2b2 + cdash;
! Predictor variable - X
! Mediator variable(s) – M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y M1W;
! Create interaction term
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:
M1W = M1*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 X (cdash);
! direct effect of X on Y
M1 ON X (a1);
M2 ON X (a2);
M2 ON M1 (d1);
M2 ON W (d2);
M2 ON M1W (d3);
! 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
a1b1 a2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM
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
a1b1 = a1*b1;
! Specific indirect effect of X on Y via M1 only
a2b2 = a2*b2;
! Specific indirect effect of X on Y via M2 only
! Conditional indirect effects of X on Y via M1 and M2 given values of W
LWa1d1b2 = a1*d1*b2 + a1*d3*b2*LOW_W;
MWa1d1b2 = a1*d1*b2 + a1*d3*b2*MED_W;
HWa1d1b2 = a1*d1*b2 + a1*d3*b2*HIGH_W;
! Index of Moderated Mediation
IMM = a1*d3*b2;
! Conditional total effects of X on Y given values of W
TOT_LOWW = LWa1d1b2 + a1b1 + a2b2 + cdash;
TOT_MEDW = MWa1d1b2 + a1b1 + a2b2 + cdash ;
TOT_HIW = HWa1d1b2 + a1b1 + a2b2 + 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;
! Create interaction term
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:
M1W = M1*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 X (cdash);
! direct effect of X on Y
M1 ON X (a1);
M2 ON X (a2);
M2 ON M1 (d1);
M2 ON W (d2);
M2 ON M1W (d3);
! 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
a1b1 a2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM
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
a1b1 = a1*b1;
! Specific indirect effect of X on Y via M1 only
a2b2 = a2*b2;
! Specific indirect effect of X on Y via M2 only
! Conditional indirect effects of X on Y via M1 and M2 given values of W
LWa1d1b2 = a1*d1*b2 + a1*d3*b2*LOW_W;
MWa1d1b2 = a1*d1*b2 + a1*d3*b2*MED_W;
HWa1d1b2 = a1*d1*b2 + a1*d3*b2*HIGH_W;
! Index of Moderated Mediation
IMM = a1*d3*b2;
! Conditional total effects of X on Y given values of W
TOT_LOWW = LWa1d1b2 + a1b1 + a2b2 + cdash;
TOT_MEDW = MWa1d1b2 + a1b1 + a2b2 + cdash ;
TOT_HIW = HWa1d1b2 + a1b1 + a2b2 + 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);