Mplus model90 模型讲解

来自图书《MPlus中介调节模型》

Mplus 复杂中介调节模型教程

  • 理论模型
  • 数学模型
  • 数学推导
  • 代码解读

理论模型

数学模型

数学公式1

模型公式:

1.  Y = b0 + b1M1 + b2M2 + b3M2W + c1'X + c2'W + c3'XW
2.  M1 = a01 + a1X
3.  M2 = a02 + a2X + d1M1

数学公式2

模型公式:

1.  Y = b0 + b1M1 + b2M2 + b3M2W + c1'X + c2'W + c3'XW
2.  M1 = a01 + a1X
3.  M2 = a02 + a2X + d1M1
步骤1:替换

Y = b0 + b1(a01 + a1X) + b2(a02 + a2X + d1(a01 + a1X)) + b3(a02 + a2X + d1(a01 + a1X))W + c1'X + c2'W + c3'XW

数学公式3

模型公式:

1.  Y = b0 + b1M1 + b2M2 + b3M2W + c1'X + c2'W + c3'XW
2.  M1 = a01 + a1X
3.  M2 = a02 + a2X + d1M1
步骤1:替换

Y = b0 + b1(a01 + a1X) + b2(a02 + a2X + d1(a01 + a1X)) + b3(a02 + a2X + d1(a01 + a1X))W + c1'X + c2'W + c3'XW
步骤2:展开括号

Y = b0 + a01b1 + a1b1X + a02b2 + a2b2X + a01d1b2 + a1d1b2X + a02b3W + a2b3XW + a01d1b3W + a1d1b3XW + c1'X + c2'W + c3'XW

数学公式4

模型公式:

1.  Y = b0 + b1M1 + b2M2 + b3M2W + c1'X + c2'W + c3'XW
2.  M1 = a01 + a1X
3.  M2 = a02 + a2X + d1M1
步骤1:替换

Y = b0 + b1(a01 + a1X) + b2(a02 + a2X + d1(a01 + a1X)) + b3(a02 + a2X + d1(a01 + a1X))W + c1'X + c2'W + c3'XW
步骤2:展开括号

Y = b0 + a01b1 + a1b1X + a02b2 + a2b2X + a01d1b2 + a1d1b2X + a02b3W + a2b3XW + a01d1b3W + a1d1b3XW + c1'X + c2'W + c3'XW
步骤3:合并同类项

Y = (b0 + a01b1 + a02b2 + a01d1b2 + a02b3W + a01d1b3W + c2'W) + (a1b1 + a2b2 + a2b3W + a1d1b2 + a1d1b3W + c1' + c3'W)X

数学公式5

模型公式:

1.  Y = b0 + b1M1 + b2M2 + b3M2W + c1'X + c2'W + c3'XW
2.  M1 = a01 + a1X
3.  M2 = a02 + a2X + d1M1
步骤1:替换

Y = b0 + b1(a01 + a1X) + b2(a02 + a2X + d1(a01 + a1X)) + b3(a02 + a2X + d1(a01 + a1X))W + c1'X + c2'W + c3'XW
步骤2:展开括号

Y = b0 + a01b1 + a1b1X + a02b2 + a2b2X + a01d1b2 + a1d1b2X + a02b3W + a2b3XW + a01d1b3W + a1d1b3XW + c1'X + c2'W + c3'XW
步骤3:合并同类项

Y = (b0 + a01b1 + a02b2 + a01d1b2 + a02b3W + a01d1b3W + c2'W) + (a1b1 + a2b2 + a2b3W + a1d1b2 + a1d1b3W + c1' + c3'W)X
步骤4:提取效应

* 间接效应 (Indirect Effects):
    * a1b1
    * a2(b2 + b3W)
    * a1d1(b2 + b3W)

* 直接效应 (Direct Effect):
    * c1' + c3'W

代码解读1

! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y

代码解读2

! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y XW M2W;

代码解读3

! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y XW M2W;
! Note that it has to be placed at end of USEVARIABLES subcommand above

代码解读4

! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y XW M2W;
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:

XW = X*W;
M2W = M2*W;

代码解读5

! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y XW M2W;
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:

XW = X*W;
M2W = M2*W;
ANALYSIS:

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

代码解读6

! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y XW M2W;
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:

XW = X*W;
M2W = M2*W;
ANALYSIS:

TYPE = GENERAL;
ESTIMATOR = ML;
BOOTSTRAP = 10000;
! In model statement name each path using parentheses

代码解读7

! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y XW M2W;
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:

XW = X*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 M2W (b3);
Y ON X (cdash1);
Y ON W (cdash2);
Y ON XW (cdash3);
M1 ON X (a1);
M2 ON X (a2);
M2 ON M1 (d1);

代码解读8

! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y XW M2W;
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:

XW = X*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 M2W (b3);
Y ON X (cdash1);
Y ON W (cdash2);
Y ON XW (cdash3);
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

代码解读9

! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y XW M2W;
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:

XW = X*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 M2W (b3);
Y ON X (cdash1);
Y ON W (cdash2);
Y ON XW (cdash3);
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 a1b1
LWa2b2 MWa2b2 HWa2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM_A IMM_B
DIR_LW DIR_MW DIR_HW
TOT_LOWW TOT_MEDW TOT_HIW);

代码解读10

! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y XW M2W;
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:

XW = X*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 M2W (b3);
Y ON X (cdash1);
Y ON W (cdash2);
Y ON XW (cdash3);
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 a1b1
LWa2b2 MWa2b2 HWa2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM_A IMM_B
DIR_LW DIR_MW DIR_HW
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

代码解读11

! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y XW M2W;
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:

XW = X*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 M2W (b3);
Y ON X (cdash1);
Y ON W (cdash2);
Y ON XW (cdash3);
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 a1b1
LWa2b2 MWa2b2 HWa2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM_A IMM_B
DIR_LW DIR_MW DIR_HW
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;

代码解读12

! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y XW M2W;
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:

XW = X*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 M2W (b3);
Y ON X (cdash1);
Y ON W (cdash2);
Y ON XW (cdash3);
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 a1b1
LWa2b2 MWa2b2 HWa2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM_A IMM_B
DIR_LW DIR_MW DIR_HW
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;
LWa2b2 = a2*b2 + a2*b3*LOW_W;
MWa2b2 = a2*b2 + a2*b3*MED_W;
HWa2b2 = a2*b2 + a2*b3*HIGH_W;
! Conditional indirect effects of X on Y via M2 only given values of W

代码解读13

! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y XW M2W;
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:

XW = X*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 M2W (b3);
Y ON X (cdash1);
Y ON W (cdash2);
Y ON XW (cdash3);
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 a1b1
LWa2b2 MWa2b2 HWa2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM_A IMM_B
DIR_LW DIR_MW DIR_HW
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;
LWa2b2 = a2*b2 + a2*b3*LOW_W;
MWa2b2 = a2*b2 + a2*b3*MED_W;
HWa2b2 = a2*b2 + a2*b3*HIGH_W;
! Conditional indirect effects of X on Y via M2 only given values of W
LWa1d1b2 = a1*d1*b2 + a1*d1*b3*LOW_W;
MWa1d1b2 = a1*d1*b2 + a1*d1*b3*MED_W;
HWa1d1b2 = a1*d1*b2 + a1*d1*b3*HIGH_W;
! Conditional indirect effects of X on Y via M1 and M2 given values of W

代码解读14

! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y XW M2W;
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:

XW = X*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 M2W (b3);
Y ON X (cdash1);
Y ON W (cdash2);
Y ON XW (cdash3);
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 a1b1
LWa2b2 MWa2b2 HWa2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM_A IMM_B
DIR_LW DIR_MW DIR_HW
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;
LWa2b2 = a2*b2 + a2*b3*LOW_W;
MWa2b2 = a2*b2 + a2*b3*MED_W;
HWa2b2 = a2*b2 + a2*b3*HIGH_W;
! Conditional indirect effects of X on Y via M2 only given values of W
LWa1d1b2 = a1*d1*b2 + a1*d1*b3*LOW_W;
MWa1d1b2 = a1*d1*b2 + a1*d1*b3*MED_W;
HWa1d1b2 = a1*d1*b2 + a1*d1*b3*HIGH_W;
! Conditional indirect effects of X on Y via M1 and M2 given values of W
! Indices of Moderated Mediation
IMM_A = a2*b3;
IMM_B = a1*d1*b3;

代码解读15

! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y XW M2W;
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:

XW = X*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 M2W (b3);
Y ON X (cdash1);
Y ON W (cdash2);
Y ON XW (cdash3);
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 a1b1
LWa2b2 MWa2b2 HWa2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM_A IMM_B
DIR_LW DIR_MW DIR_HW
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;
LWa2b2 = a2*b2 + a2*b3*LOW_W;
MWa2b2 = a2*b2 + a2*b3*MED_W;
HWa2b2 = a2*b2 + a2*b3*HIGH_W;
! Conditional indirect effects of X on Y via M2 only given values of W
LWa1d1b2 = a1*d1*b2 + a1*d1*b3*LOW_W;
MWa1d1b2 = a1*d1*b2 + a1*d1*b3*MED_W;
HWa1d1b2 = a1*d1*b2 + a1*d1*b3*HIGH_W;
! Conditional indirect effects of X on Y via M1 and M2 given values of W
! Indices of Moderated Mediation
IMM_A = a2*b3;
IMM_B = a1*d1*b3;
! Conditional direct effects of X on Y given values of W
DIR_LW = cdash1 + cdash3*LOW_W;
DIR_MW = cdash1 + cdash3*MED_W;;
DIR_HW = cdash1 + cdash3*HIGH_W;;

代码解读16

! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y XW M2W;
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:

XW = X*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 M2W (b3);
Y ON X (cdash1);
Y ON W (cdash2);
Y ON XW (cdash3);
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 a1b1
LWa2b2 MWa2b2 HWa2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM_A IMM_B
DIR_LW DIR_MW DIR_HW
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;
LWa2b2 = a2*b2 + a2*b3*LOW_W;
MWa2b2 = a2*b2 + a2*b3*MED_W;
HWa2b2 = a2*b2 + a2*b3*HIGH_W;
! Conditional indirect effects of X on Y via M2 only given values of W
LWa1d1b2 = a1*d1*b2 + a1*d1*b3*LOW_W;
MWa1d1b2 = a1*d1*b2 + a1*d1*b3*MED_W;
HWa1d1b2 = a1*d1*b2 + a1*d1*b3*HIGH_W;
! Conditional indirect effects of X on Y via M1 and M2 given values of W
! Indices of Moderated Mediation
IMM_A = a2*b3;
IMM_B = a1*d1*b3;
! Conditional direct effects of X on Y given values of W
DIR_LW = cdash1 + cdash3*LOW_W;
DIR_MW = cdash1 + cdash3*MED_W;;
DIR_HW = cdash1 + cdash3*HIGH_W;;
! Conditional total effects of X on Y given values of W
TOT_LOWW = LWa1d1b2 + LWa2b2 + a1b1 + DIR_LW;
TOT_MEDW = MWa1d1b2 + MWa2b2 + a1b1 + DIR_MW;
TOT_HIW = HWa1d1b2 + HWa2b2 + a1b1 + DIR_HW;

代码解读17

! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y XW M2W;
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:

XW = X*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 M2W (b3);
Y ON X (cdash1);
Y ON W (cdash2);
Y ON XW (cdash3);
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 a1b1
LWa2b2 MWa2b2 HWa2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM_A IMM_B
DIR_LW DIR_MW DIR_HW
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;
LWa2b2 = a2*b2 + a2*b3*LOW_W;
MWa2b2 = a2*b2 + a2*b3*MED_W;
HWa2b2 = a2*b2 + a2*b3*HIGH_W;
! Conditional indirect effects of X on Y via M2 only given values of W
LWa1d1b2 = a1*d1*b2 + a1*d1*b3*LOW_W;
MWa1d1b2 = a1*d1*b2 + a1*d1*b3*MED_W;
HWa1d1b2 = a1*d1*b2 + a1*d1*b3*HIGH_W;
! Conditional indirect effects of X on Y via M1 and M2 given values of W
! Indices of Moderated Mediation
IMM_A = a2*b3;
IMM_B = a1*d1*b3;
! Conditional direct effects of X on Y given values of W
DIR_LW = cdash1 + cdash3*LOW_W;
DIR_MW = cdash1 + cdash3*MED_W;;
DIR_HW = cdash1 + cdash3*HIGH_W;;
! Conditional total effects of X on Y given values of W
TOT_LOWW = LWa1d1b2 + LWa2b2 + a1b1 + DIR_LW;
TOT_MEDW = MWa1d1b2 + MWa2b2 + a1b1 + DIR_MW;
TOT_HIW = HWa1d1b2 + HWa2b2 + a1b1 + DIR_HW;
! 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

代码解读18

! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y XW M2W;
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:

XW = X*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 M2W (b3);
Y ON X (cdash1);
Y ON W (cdash2);
Y ON XW (cdash3);
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 a1b1
LWa2b2 MWa2b2 HWa2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM_A IMM_B
DIR_LW DIR_MW DIR_HW
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;
LWa2b2 = a2*b2 + a2*b3*LOW_W;
MWa2b2 = a2*b2 + a2*b3*MED_W;
HWa2b2 = a2*b2 + a2*b3*HIGH_W;
! Conditional indirect effects of X on Y via M2 only given values of W
LWa1d1b2 = a1*d1*b2 + a1*d1*b3*LOW_W;
MWa1d1b2 = a1*d1*b2 + a1*d1*b3*MED_W;
HWa1d1b2 = a1*d1*b2 + a1*d1*b3*HIGH_W;
! Conditional indirect effects of X on Y via M1 and M2 given values of W
! Indices of Moderated Mediation
IMM_A = a2*b3;
IMM_B = a1*d1*b3;
! Conditional direct effects of X on Y given values of W
DIR_LW = cdash1 + cdash3*LOW_W;
DIR_MW = cdash1 + cdash3*MED_W;;
DIR_HW = cdash1 + cdash3*HIGH_W;;
! Conditional total effects of X on Y given values of W
TOT_LOWW = LWa1d1b2 + LWa2b2 + a1b1 + DIR_LW;
TOT_MEDW = MWa1d1b2 + MWa2b2 + a1b1 + DIR_MW;
TOT_HIW = HWa1d1b2 + HWa2b2 + a1b1 + DIR_HW;
! 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;

代码解读19

! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y XW M2W;
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:

XW = X*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 M2W (b3);
Y ON X (cdash1);
Y ON W (cdash2);
Y ON XW (cdash3);
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 a1b1
LWa2b2 MWa2b2 HWa2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM_A IMM_B
DIR_LW DIR_MW DIR_HW
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;
LWa2b2 = a2*b2 + a2*b3*LOW_W;
MWa2b2 = a2*b2 + a2*b3*MED_W;
HWa2b2 = a2*b2 + a2*b3*HIGH_W;
! Conditional indirect effects of X on Y via M2 only given values of W
LWa1d1b2 = a1*d1*b2 + a1*d1*b3*LOW_W;
MWa1d1b2 = a1*d1*b2 + a1*d1*b3*MED_W;
HWa1d1b2 = a1*d1*b2 + a1*d1*b3*HIGH_W;
! Conditional indirect effects of X on Y via M1 and M2 given values of W
! Indices of Moderated Mediation
IMM_A = a2*b3;
IMM_B = a1*d1*b3;
! Conditional direct effects of X on Y given values of W
DIR_LW = cdash1 + cdash3*LOW_W;
DIR_MW = cdash1 + cdash3*MED_W;;
DIR_HW = cdash1 + cdash3*HIGH_W;;
! Conditional total effects of X on Y given values of W
TOT_LOWW = LWa1d1b2 + LWa2b2 + a1b1 + DIR_LW;
TOT_MEDW = MWa1d1b2 + MWa2b2 + a1b1 + DIR_MW;
TOT_HIW = HWa1d1b2 + HWa2b2 + a1b1 + DIR_HW;
! 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;

代码解读20

! Predictor variable - X
! Mediator variable(s) - M1, M2
! Moderator variable(s) - W
! Outcome variable - Y
USEVARIABLES = X M1 M2 W Y XW M2W;
! Note that it has to be placed at end of USEVARIABLES subcommand above
DEFINE:

XW = X*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 M2W (b3);
Y ON X (cdash1);
Y ON W (cdash2);
Y ON XW (cdash3);
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 a1b1
LWa2b2 MWa2b2 HWa2b2
LWa1d1b2 MWa1d1b2 HWa1d1b2
IMM_A IMM_B
DIR_LW DIR_MW DIR_HW
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;
LWa2b2 = a2*b2 + a2*b3*LOW_W;
MWa2b2 = a2*b2 + a2*b3*MED_W;
HWa2b2 = a2*b2 + a2*b3*HIGH_W;
! Conditional indirect effects of X on Y via M2 only given values of W
LWa1d1b2 = a1*d1*b2 + a1*d1*b3*LOW_W;
MWa1d1b2 = a1*d1*b2 + a1*d1*b3*MED_W;
HWa1d1b2 = a1*d1*b2 + a1*d1*b3*HIGH_W;
! Conditional indirect effects of X on Y via M1 and M2 given values of W
! Indices of Moderated Mediation
IMM_A = a2*b3;
IMM_B = a1*d1*b3;
! Conditional direct effects of X on Y given values of W
DIR_LW = cdash1 + cdash3*LOW_W;
DIR_MW = cdash1 + cdash3*MED_W;;
DIR_HW = cdash1 + cdash3*HIGH_W;;
! Conditional total effects of X on Y given values of W
TOT_LOWW = LWa1d1b2 + LWa2b2 + a1b1 + DIR_LW;
TOT_MEDW = MWa1d1b2 + MWa2b2 + a1b1 + DIR_MW;
TOT_HIW = HWa1d1b2 + HWa2b2 + a1b1 + DIR_HW;
! 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);

资源汇总

  • 本视频讲义地址: https://mlln.cn/mplus-model-templates/model90.html
  • 图书《MPlus中介调节模型》打包下载: 点击下载
  • 图书《MPlus中介调节模型》在线看: 点击查看
  • 视频教程: 点击这里打开视频
  • Mplus 模型模板教程列表: https://mlln.cn/mplus-model-templates
  • 统计咨询: https://wx.zsxq.com/group/88888188828842