作者: 崔颖(中央财经大学)
Source: HOW CAN I DO MODERATED MEDIATION IN STATA? | STATA FAQ 连享会 最新专题 直播
连享会-知乎推文列表
Note: 助教招聘信息请进入「课程主页」查看。
http://qr32.cn/BlTL43 (二维码自动识别)
https://gitee.com/arlionn/DSGE (二维码自动识别)
1. 中介效应和调节效应的定义
首先,我们来区分两个相似的概念:中介效应 (Mediation) 和 调节效应 (Moderation) 。
中介变量 是介于自变量与因变量之间的,它可以部分地解释自变量对因变量的间接影响,即自变量对因变量的影响可以分为直接效应和间接效应两部分。
调节变量 影响模型中其他的变量的作用效果,也就是说,模型中特定变量的作用效果会依赖于调节变量的取值大小。
调节中介效应 (Moderated Mediation) 是指调节变量的取值大小影响中介变量所能解释的间接效应的幅度,这被称为 条件间接效应。在调节变量取特定值得条件下,解释间接效应的影响效果。
Muller 等人 (2005) 在其文章中 When moderation is mediated and mediation is moderated 中提出了三种基本模型来解释调节中介效应和中介调节效应。其中, Mo 表示调节变量,Me 表示中介变量,
第一步,解释变量 (X) 和被解释变量 (Y) 之间的调节效应也被称为全局处理效应 (如图中路径 C)。实际上,X 对 Y 的影响可以被分解为 A*B+C。
为了理解中介调节效应,首先明确全局调节效应的效果由
第二步,解释变量和中介变量之间的调节效应 (如图中路径 A)。
若
第三步,解释变量和被解释变量与中介变量和被解释变量之间的调节效应(如图中路径 A和路径B)。
若第二步中的
若第二步中的
2. 调节中介效应的检验方法
Hayes (2013) 和 Preacher (2007) 详述了调节中介效应的理论背景和框架,他们也提供了检验调节中介效应和计算间接效应大小的方法。
第一种方法是基于正态分布假定的。这种方法理论上很有效,但实际中条件间接效应的分布往往不呈正态,通常会有各异的偏斜和峰态。基于正态分布方法的置信区间和假设检验通常不够准确。第二种方法使用自举法 (Bootstrapping) 获得标准误和置信区间。尽管这种方法的计算速度大大降低,但此时置信区间的计算是修正偏误且非对称的,更好的反映了条件间接效应样本分布的真实情况。
接下来,本文会介绍 Preacher 文章中的五个模型。每个模型都会先使用 sem
和 nlcom
命令进行基于正态分布假定的方法估计,然后再介绍如何获得标准误和置信区间的自举估计。
为了计算条件间接效果的大小,我们需要得到以下两个模型的估计系数:模型一用中介变量对解释变量进行回归,模型二用被解释变量对解释变量进行回归。此处,可以使用 Stata 命令 sem
方便得到上述估计系数。条件间接效应可以通过将结构方程模型 (Structural Equation Model) 的估计系数与调节变量给定的取值相乘得到。
对于 Preacher 文章五个模型中的前四个,我们将计算调节变量取三个值 (低 (均值减一个标准差),中 (均值),高 (均值加一个标准差)) 时,分别对应的条件间接效应。其中,模型4 由于涉及到两个调节变量,将会产生 3*3=9 种结果。
连享会 最新专题 直播
2.1 调用数据并定义变量
use "https://stats.idre.ucla.edu/stat/data/hsb2", clear
rename science y // 被解释变量
rename math x // 解释变量
rename read m // 中介变量
rename write w // 调节变量1
rename socst z // 调节变量2
2.2 模型构建与估计
模型 1:解释变量同时也是中介变量与被解释变量之间的调节变量
对模型 1 进行正态分布假定估计:
. summarize x
. global m = r(mean)
. global s = r(sd)
. generate mx = m*x // mv by iv interaction
. sem (m <- x)(y <- m x mx)
输出结果如下:
Endogenous variables
Observed: m y
Exogenous variables
Observed: x mx
Fitting target model:
Iteration 0: log likelihood = -3585.6581
Iteration 1: log likelihood = -3585.6581
Structural equation model Number of obs = 200
Estimation method = ml
Log likelihood = -3585.6581
------------------------------------------------------------------------------
| OIM
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Structural |
m |
x | .724807 .0579824 12.50 0.000 .6111636 .8384504
_cons | 14.07254 3.100201 4.54 0.000 7.996255 20.14882
-----------+----------------------------------------------------------------
y |
m | .9766164 .2875081 3.40 0.001 .4131109 1.540122
x | 1.03094 .2969707 3.47 0.001 .4488881 1.612992
mx | -.0115869 .0053091 -2.18 0.029 -.0219926 -.0011812
_cons | -20.83921 15.16952 -1.37 0.170 -50.57092 8.892495
-------------+----------------------------------------------------------------
var(e.m)| 58.71925 5.871925 48.26811 71.43329
var(e.y)| 49.70994 4.970994 40.86232 60.47326
------------------------------------------------------------------------------
LR test of model vs. saturated: chi2(1) = 594.37, Prob > chi2 = 0.0000
计算特定调节变量取值下的系数:
. nlcom _b[m:x]*(_b[y:m]+($m-$s)*_b[y:mx]) /* mean - 1 sd */
_nl_1: _b[m:x]*(_b[y:m]+(52.645-9.368447794077296)*_b[y:mx])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .3444105 .0656615 5.25 0.000 .2157163 .4731048
------------------------------------------------------------------------------
. nlcom _b[m:x]*(_b[y:m]+($m)*_b[y:mx]) /* mean */
_nl_1: _b[m:x]*(_b[y:m]+(52.645)*_b[y:mx])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .2657319 .0517277 5.14 0.000 .1643474 .3671164
------------------------------------------------------------------------------
. nlcom _b[m:x]*(_b[y:m]+($m+$s)*_b[y:mx]) /* mean + 1 sd */
_nl_1: _b[m:x]*(_b[y:m]+(52.645+9.368447794077296)*_b[y:mx])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1870532 .0609803 3.07 0.002 .067534 .3065724
------------------------------------------------------------------------------
在此例中,条件间接效应随着调节变量取值的增加而减小。接下来,我们使用如下的bootstrap
命令进行 500 次循环计算。
capture program drop bootm1
program bootm1, rclass
sem (m <- x)(y <- m x mx)
return scalar cielw = _b[m:x]*(_b[y:m]+($m-$s)*_b[y:mx])
return scalar ciemn = _b[m:x]*(_b[y:m]+($m)*_b[y:mx])
return scalar ciehi = _b[m:x]*(_b[y:m]+($m+$s)*_b[y:mx])
end
. bootstrap r(cielw) r(ciemn) r(ciehi), reps(500) nodots: bootm1
结果如下:
Bootstrap results Number of obs = 200
Replications = 500
command: bootm1
_bs_1: r(cielw)
_bs_2: r(ciemn)
_bs_3: r(ciehi)
------------------------------------------------------------------------------
| Observed Bootstrap Normal-based
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_bs_1 | .3444105 .0616473 5.59 0.000 .223584 .4652371
_bs_2 | .2657319 .0524074 5.07 0.000 .1630153 .3684484
_bs_3 | .1870532 .0621991 3.01 0.003 .0651451 .3089613
------------------------------------------------------------------------------
. estat boot, bc percentile
Bootstrap results Number of obs = 200
Replications = 500
command: bootm1
_bs_1: r(cielw)
_bs_2: r(ciemn)
_bs_3: r(ciehi)
------------------------------------------------------------------------------
| Observed Bootstrap
| Coef. Bias Std. Err. [95% Conf. Interval]
-------------+----------------------------------------------------------------
_bs_1 | .34441055 -.0064576 .06164735 .2203172 .4564181 (P)
| .2290775 .4607842 (BC)
_bs_2 | .26573187 -.0042591 .05240738 .1586023 .3617616 (P)
| .1702687 .3684798 (BC)
_bs_3 | .18705319 -.0020605 .06219915 .0653596 .3086919 (P)
| .0642492 .3030243 (BC)
------------------------------------------------------------------------------
(P) percentile confidence interval
(BC) bias-corrected confidence interval
模型 2:调节变量影响解释变量与中介变量之间的关系
. summarize w
. global m=r(mean)
. global s=r(sd)
. generate wx=w*x /* moderator 1 by iv interaction */
. sem (m <- x w wx)(y <- m x w wx) // SEM 模型
Endogenous variables
Observed: m y
Exogenous variables
Observed: x w wx
Fitting target model:
Iteration 0: log likelihood = -3919.1644
Iteration 1: log likelihood = -3919.1644
Structural equation model Number of obs = 200
Estimation method = ml
Log likelihood = -3919.1644
------------------------------------------------------------------------------
| OIM
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Structural |
m <- |
x | .2707428 .3780083 0.72 0.474 -.4701398 1.011625
w | .1041694 .3417056 0.30 0.760 -.5655613 .7739002
wx | .0044859 .0066954 0.67 0.503 -.0086368 .0176087
_cons | 19.7711 18.53835 1.07 0.286 -16.56341 56.1056
-----------+----------------------------------------------------------------
y <- |
m | .3057916 .0677692 4.51 0.000 .1729665 .4386168
x | .7902703 .3627478 2.18 0.029 .0792976 1.501243
w | .6316515 .3275671 1.93 0.054 -.0103682 1.273671
wx | -.008533 .0064241 -1.33 0.184 -.021124 .0040579
_cons | -14.88752 17.81763 -0.84 0.403 -49.80943 20.03438
-------------+----------------------------------------------------------------
var(e.m)| 52.63581 5.263581 43.26744 64.03265
var(e.y)| 48.3477 4.83477 39.74254 58.81607
------------------------------------------------------------------------------
LR test of model vs. saturated: chi2(0) = 0.00, Prob > chi2 = .
. nlcom (_b[m:x]+($m-$s)*_b[m:wx])*_b[y:m] /* mean - 1 sd */
_nl_1: (_b[m:x]+(52.775-9.47858602138653)*_b[m:wx])*_b[y:m]
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1421829 .0455118 3.12 0.002 .0529814 .2313843
------------------------------------------------------------------------------
. nlcom (_b[m:x]+($m)*_b[m:wx])*_b[y:m] /* mean */
_nl_1: (_b[m:x]+(52.775)*_b[m:wx])*_b[y:m]
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1551852 .0408543 3.80 0.000 .0751121 .2352582
------------------------------------------------------------------------------
. nlcom (_b[m:x]+($m+$s)*_b[m:wx])*_b[y:m] /* mean + 1 sd */
_nl_1: (_b[m:x]+(52.775+9.47858602138653)*_b[m:wx])*_b[y:m]
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1681874 .0451294 3.73 0.000 .0797355 .2566394
------------------------------------------------------------------------------
capture program drop bootm2
program bootm2, rclass
sem (m <- x w wx)(y <- m x w wx)
return scalar cielw = (_b[m:x]+($m-$s)*_b[m:wx])*_b[y:m]
return scalar ciemn = (_b[m:x]+($m)*_b[m:wx])*_b[y:m]
return scalar ciehi = (_b[m:x]+($m+$s)*_b[m:wx])*_b[y:m]
end
. bootstrap r(cielw) r(ciemn) r(ciehi), reps(500) nodots: bootm2
Bootstrap results Number of obs = 200
Replications = 500
command: bootm2
_bs_1: r(cielw)
_bs_2: r(ciemn)
_bs_3: r(ciehi)
------------------------------------------------------------------------------
| Observed Bootstrap Normal-based
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_bs_1 | .1421829 .047612 2.99 0.003 .048865 .2355007
_bs_2 | .1551852 .0409495 3.79 0.000 .0749256 .2354447
_bs_3 | .1681874 .0423557 3.97 0.000 .0851717 .2512031
------------------------------------------------------------------------------
. estat boot, bc percentile
Bootstrap results Number of obs = 200
Replications = 500
command: bootm2
_bs_1: r(cielw)
_bs_2: r(ciemn)
_bs_3: r(ciehi)
------------------------------------------------------------------------------
| Observed Bootstrap
| Coef. Bias Std. Err. [95% Conf. Interval]
-------------+----------------------------------------------------------------
_bs_1 | .14218287 .0009392 .04761201 .0579299 .2551758 (P)
| .0579299 .2551758 (BC)
_bs_2 | .15518515 .0001497 .0409495 .078383 .242382 (P)
| .078383 .242382 (BC)
_bs_3 | .16818743 -.0006398 .04235573 .0869211 .2532646 (P)
| .089544 .2589626 (BC)
------------------------------------------------------------------------------
(P) percentile confidence interval
(BC) bias-corrected confidence interval
在此例中,条件间接效应随着调节变量取值的增加而缓慢增长。
模型 3:调节变量影响中介变量与被解释变量之间的关系
. summarize w
. global m=r(mean)
. global s=r(sd)
. generate mw=m*w /* mv by moderator 1 interaction */
. sem (m <- x)(y <- m x w mw)
Endogenous variables
Observed: m y
Exogenous variables
Observed: x w mw
Fitting target model:
Iteration 0: log likelihood = -4260.6166
Iteration 1: log likelihood = -4260.6166
Structural equation model Number of obs = 200
Estimation method = ml
Log likelihood = -4260.6166
------------------------------------------------------------------------------
| OIM
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Structural |
m <- |
x | .724807 .0579824 12.50 0.000 .6111636 .8384504
_cons | 14.07254 3.100201 4.54 0.000 7.996255 20.14882
-----------+----------------------------------------------------------------
y <- |
m | .8193599 .3169173 2.59 0.010 .1982135 1.440506
x | .33696 .0761398 4.43 0.000 .1877287 .4861913
w | .6739726 .2880423 2.34 0.019 .1094201 1.238525
mw | -.0095993 .00574 -1.67 0.094 -.0208495 .0016509
_cons | -17.23954 15.65376 -1.10 0.271 -47.92034 13.44126
-------------+----------------------------------------------------------------
var(e.m)| 58.71925 5.871925 48.26811 71.43329
var(e.y)| 48.10157 4.810157 39.54022 58.51664
------------------------------------------------------------------------------
LR test of model vs. saturated: chi2(2) = 639.91, Prob > chi2 = 0.0000
. nlcom _b[m:x]*(_b[y:m]+($m-$s)*_b[y:mw]) /* mean - 1 sd */
_nl_1: _b[m:x]*(_b[y:m]+(52.775-9.47858602138653)*_b[y:mw])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .2926372 .0700399 4.18 0.000 .1553616 .4299129
------------------------------------------------------------------------------
. nlcom _b[m:x]*(_b[y:m]+($m)*_b[y:mw]) /* mean */
_nl_1: _b[m:x]*(_b[y:m]+(52.775)*_b[y:mw])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .2266887 .0524176 4.32 0.000 .1239522 .3294253
------------------------------------------------------------------------------
. nlcom _b[m:x]*(_b[y:m]+($m+$s)*_b[y:mw]) /* mean + 1 sd */
_nl_1: _b[m:x]*(_b[y:m]+(52.775+9.47858602138653)*_b[y:mw])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1607402 .0612818 2.62 0.009 .04063 .2808504
------------------------------------------------------------------------------
在此例中,条件间接效应随着调节变量取值的增加而减少。
capture program drop bootm3
program bootm3, rclass
sem (m <- x)(y <- m x w mw)
return scalar cielw = _b[m:x]*(_b[y:m]+($m-$s)*_b[y:mw])
return scalar ciemn = _b[m:x]*(_b[y:m]+($m)*_b[y:mw])
return scalar ciehi = _b[m:x]*(_b[y:m]+($m+$s)*_b[y:mw])
end
. bootstrap r(cielw) r(ciemn) r(ciehi), reps(500) nodots: bootm3
Bootstrap results Number of obs = 200
Replications = 500
command: bootm3
_bs_1: r(cielw)
_bs_2: r(ciemn)
_bs_3: r(ciehi)
------------------------------------------------------------------------------
| Observed Bootstrap Normal-based
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_bs_1 | .2926372 .0666315 4.39 0.000 .1620418 .4232326
_bs_2 | .2266887 .0531356 4.27 0.000 .1225448 .3308326
_bs_3 | .1607402 .0615717 2.61 0.009 .0400619 .2814185
------------------------------------------------------------------------------
. estat boot, bc percentile
Bootstrap results Number of obs = 200
Replications = 500
command: bootm3
_bs_1: r(cielw)
_bs_2: r(ciemn)
_bs_3: r(ciehi)
------------------------------------------------------------------------------
| Observed Bootstrap
| Coef. Bias Std. Err. [95% Conf. Interval]
-------------+----------------------------------------------------------------
_bs_1 | .29263724 -.0008677 .06663153 .1549403 .4144395 (P)
| .1554288 .4178429 (BC)
_bs_2 | .22668872 .0000859 .05313561 .1177044 .3335583 (P)
| .1170573 .3309805 (BC)
_bs_3 | .1607402 .0010394 .06157172 .0423122 .2809089 (P)
| .0423122 .2809089 (BC)
------------------------------------------------------------------------------
(P) percentile confidence interval
(BC) bias-corrected confidence interval
模型 4:两个不同的调节变量,一个影响解释变量与中介变量之间的关系,另一个影响中介变量与被解释变量之间的关系
. summarize w
. global m1 = r(mean)
. global s1 = r(sd)
. summarize z
. global m2 = r(mean)
. global s2 = r(sd)
. capture generate wx=w*x // moderator 1 by iv interaction
. gen mz=m*z // mv by moderator 2 interaction
. sem (m <- x w wx)(y <- m x w wx z mz)
Endogenous variables
Observed: m y
Exogenous variables
Observed: x w wx z mz
Fitting target model:
Iteration 0: log likelihood = -6096.1477
Iteration 1: log likelihood = -6096.1477
Structural equation model Number of obs = 200
Estimation method = ml
Log likelihood = -6096.1477
------------------------------------------------------------------------------
| OIM
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Structural |
m <- |
x | .2707428 .3780083 0.72 0.474 -.4701398 1.011625
w | .1041694 .3417056 0.30 0.760 -.5655613 .7739002
wx | .0044859 .0066954 0.67 0.503 -.0086368 .0176087
_cons | 19.7711 18.53835 1.07 0.286 -16.56341 56.1056
-----------+----------------------------------------------------------------
y <- |
m | .4013056 .282893 1.42 0.156 -.1531546 .9557658
x | .7571766 .3864076 1.96 0.050 -.0001684 1.514522
w | .6031543 .3562554 1.69 0.090 -.0950935 1.301402
wx | -.0078215 .0069183 -1.13 0.258 -.021381 .0057381
z | .0553245 .2661857 0.21 0.835 -.4663899 .5770389
mz | -.0015944 .0050813 -0.31 0.754 -.0115536 .0083647
_cons | -17.0724 19.0314 -0.90 0.370 -54.37327 20.22847
-------------+----------------------------------------------------------------
var(e.m)| 52.63581 5.263581 43.26744 64.03265
var(e.y)| 48.28407 4.828407 39.69024 58.73866
------------------------------------------------------------------------------
LR test of model vs. saturated: chi2(2) = 571.85, Prob > chi2 = 0.0000
. nlcom (_b[m:x]+($m1-$s1)*_b[m:wx])*(_b[y:m]+($m2-$s2)*_b[y:mz]) /* mean1 - 1 sd1; mean2 - 1 sd2 */
_nl_1: (_b[m:x]+(52.775-9.47858602138653)*_b[m:wx])*(_b[y:m]+(52.405-10.7357934642267)*_b[y:mz])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1557016 .0568792 2.74 0.006 .0442203 .2671828
------------------------------------------------------------------------------
. nlcom (_b[m:x]+($m1)*_b[m:wx])*(_b[y:m]+($m2-$s2)*_b[y:mz]) /* mean1; mean2 - 1 sd2 */
_nl_1: (_b[m:x]+(52.775)*_b[m:wx])*(_b[y:m]+(52.405-10.7357934642267)*_b[y:mz])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1699401 .0538198 3.16 0.002 .0644552 .275425
------------------------------------------------------------------------------
. nlcom (_b[m:x]+($m1+$s1)*_b[m:wx])*(_b[y:m]+($m2-$s2)*_b[y:mz]) /* mean1 + 1 sd1; mean2 - 1 sd2 */
_nl_1: (_b[m:x]+(52.775+9.47858602138653)*_b[m:wx])*(_b[y:m]+(52.405-10.7357934642267)*_b[y:mz])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1841786 .059107 3.12 0.002 .068331 .3000263
------------------------------------------------------------------------------
. nlcom (_b[m:x]+($m1-$s1)*_b[m:wx])*(_b[y:m]+($m2)*_b[y:mz]) /* mean1 - 1 sd1; mean2 */
_nl_1: (_b[m:x]+(52.775-9.47858602138653)*_b[m:wx])*(_b[y:m]+(52.405)*_b[y:mz])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1477424 .04785 3.09 0.002 .0539581 .2415267
------------------------------------------------------------------------------
nlcom (_b[m:x]+($m1)*_b[m:wx])*(_b[y:m]+($m2)*_b[y:mz]) /* mean1; mean2 */
_nl_1: (_b[m:x]+(52.775)*_b[m:wx])*(_b[y:m]+(52.405)*_b[y:mz])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1612531 .0431911 3.73 0.000 .0766001 .2459061
------------------------------------------------------------------------------
. nlcom (_b[m:x]+($m1+$s1)*_b[m:wx])*(_b[y:m]+($m2)*_b[y:mz]) /* mean1 + 1 sd1; mean2 */
_nl_1: (_b[m:x]+(52.775+9.47858602138653)*_b[m:wx])*(_b[y:m]+(52.405)*_b[y:mz])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1747638 .0476804 3.67 0.000 .081312 .2682156
------------------------------------------------------------------------------
. nlcom (_b[m:x]+($m1-$s1)*_b[m:wx])*(_b[y:m]+($m2+$s2)*_b[y:mz]) /* mean1 - 1 sd1; mean2 + 1 sd */
_nl_1: (_b[m:x]+(52.775-9.47858602138653)*_b[m:wx])*(_b[y:m]+(52.405+10.73579
> 34642267)*_b[y:mz])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1397833 .0513566 2.72 0.006 .0391261 .2404404
------------------------------------------------------------------------------
. nlcom (_b[m:x]+($m1)*_b[m:wx])*(_b[y:m]+($m2+$s2)*_b[y:mz]) /* mean1; mean2 + 1 sd */
_nl_1: (_b[m:x]+(52.775)*_b[m:wx])*(_b[y:m]+(52.405+10.7357934642267)*_b[y:mz])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1525661 .0486854 3.13 0.002 .0571445 .2479878
------------------------------------------------------------------------------
. nlcom (_b[m:x]+($m1+$s1)*_b[m:wx])*(_b[y:m]+($m2+$s2)*_b[y:mz]) /* mean1 + 1 sd1; mean2 + 1 sd */
_nl_1: (_b[m:x]+(52.775+9.47858602138653)*_b[m:wx])*(_b[y:m]+(52.405+10.7357934642267)*_b[y:mz])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .165349 .0534577 3.09 0.002 .0605738 .2701241
------------------------------------------------------------------------------
自举法估计结果如下:
capture program drop bootm4
program bootm4, rclass
sem (m <- x w wx)(y <- m x w wx z mz)
return scalar ciell = (_b[m:x]+($m1-$s1)*_b[m:wx])*(_b[y:m]+($m2-$s2)*_b[y:mz])
return scalar cieml = (_b[m:x]+($m1)*_b[m:wx])*(_b[y:m]+($m2-$s2)*_b[y:mz])
return scalar ciehl = (_b[m:x]+($m1+$s1)*_b[m:wx])*(_b[y:m]+($m2-$s2)*_b[y:mz])
return scalar cielm = (_b[m:x]+($m1-$s1)*_b[m:wx])*(_b[y:m]+($m2)*_b[y:mz])
return scalar ciemm = (_b[m:x]+($m1)*_b[m:wx])*(_b[y:m]+($m2)*_b[y:mz])
return scalar ciehm = (_b[m:x]+($m1+$s1)*_b[m:wx])*(_b[y:m]+($m2)*_b[y:mz])
return scalar cielh = (_b[m:x]+($m1-$s1)*_b[m:wx])*(_b[y:m]+($m2+$s2)*_b[y:mz])
return scalar ciemh = (_b[m:x]+($m1)*_b[m:wx])*(_b[y:m]+($m2+$s2)*_b[y:mz])
return scalar ciehh = (_b[m:x]+($m1+$s1)*_b[m:wx])*(_b[y:m]+($m2+$s2)*_b[y:mz])
end
. bootstrap r(ciell) r(cieml) r(ciehl) r(cielm) r(ciemm) r(ciehm) ///
r(cielh) r(ciemh) r(ciehh), reps(500) nodots: bootm4
Bootstrap results Number of obs = 200
Replications = 500
command: bootm4
_bs_1: r(ciell)
_bs_2: r(cieml)
_bs_3: r(ciehl)
_bs_4: r(cielm)
_bs_5: r(ciemm)
_bs_6: r(ciehm)
_bs_7: r(cielh)
_bs_8: r(ciemh)
_bs_9: r(ciehh)
------------------------------------------------------------------------------
| Observed Bootstrap Normal-based
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_bs_1 | .1557016 .0649863 2.40 0.017 .0283307 .2830725
_bs_2 | .1699401 .0621157 2.74 0.006 .0481956 .2916846
_bs_3 | .1841786 .0671694 2.74 0.006 .052529 .3158283
_bs_4 | .1477424 .0487353 3.03 0.002 .0522231 .2432618
_bs_5 | .1612531 .0445524 3.62 0.000 .0739321 .2485741
_bs_6 | .1747638 .0493391 3.54 0.000 .078061 .2714666
_bs_7 | .1397833 .0492498 2.84 0.005 .0432554 .2363111
_bs_8 | .1525661 .0472475 3.23 0.001 .0599627 .2451695
_bs_9 | .165349 .0528395 3.13 0.002 .0617855 .2689124
------------------------------------------------------------------------------
. estat boot, bc percentile
Bootstrap results Number of obs = 200
Replications = 500
command: bootm4
_bs_1: r(ciell)
_bs_2: r(cieml)
_bs_3: r(ciehl)
_bs_4: r(cielm)
_bs_5: r(ciemm)
_bs_6: r(ciehm)
_bs_7: r(cielh)
_bs_8: r(ciemh)
_bs_9: r(ciehh)
------------------------------------------------------------------------------
| Observed Bootstrap
| Coef. Bias Std. Err. [95% Conf. Interval]
-------------+----------------------------------------------------------------
_bs_1 | .15570156 -.0011114 .06498635 .0403215 .2988805 (P)
| .0505215 .3103726 (BC)
_bs_2 | .16994009 -.0011208 .06211569 .0493589 .2907081 (P)
| .0592202 .3041216 (BC)
_bs_3 | .18417863 -.0011303 .06716942 .056527 .3229917 (P)
| .0683613 .3390853 (BC)
_bs_4 | .14774241 -.0025282 .04873525 .0589332 .2458749 (P)
| .0740234 .2873931 (BC)
_bs_5 | .1612531 -.002414 .04455236 .0787119 .2513106 (P)
| .0928683 .2640307 (BC)
_bs_6 | .17476379 -.0022999 .04933908 .0872108 .2716488 (P)
| .0949407 .2876344 (BC)
_bs_7 | .13978326 -.0039449 .04924982 .0522442 .2376913 (P)
| .0635381 .2752829 (BC)
_bs_8 | .15256611 -.0037072 .04724748 .0625553 .2519639 (P)
| .0673052 .2589675 (BC)
_bs_9 | .16534895 -.0034695 .05283947 .0625117 .2702666 (P)
| .0756997 .2865739 (BC)
------------------------------------------------------------------------------
(P) percentile confidence interval
(BC) bias-corrected confidence interval
模型 5:一个调节变量同时影响解释变量与中介变量之间的关系及中介变量与被解释变量之间的关系
. summarize w
. global m = r(mean)
. global s = r(sd)
. capture generate wx = w*x // moderator 1 by iv interaction
. capture generate mw = m*w // mv by moderator 1 interaction
. sem (m <- x w wx)(y <- m x w wx mw)
Endogenous variables
Observed: m y
Exogenous variables
Observed: x w wx mw
Fitting target model:
Iteration 0: log likelihood = -5398.1882
Iteration 1: log likelihood = -5398.1882
Structural equation model Number of obs = 200
Estimation method = ml
Log likelihood = -5398.1882
------------------------------------------------------------------------------
| OIM
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
Structural |
m <- |
x | .2707428 .3780083 0.72 0.474 -.4701398 1.011625
w | .1041694 .3417056 0.30 0.760 -.5655613 .7739002
wx | .0044859 .0066954 0.67 0.503 -.0086368 .0176087
_cons | 19.7711 18.53835 1.07 0.286 -16.56341 56.1056
-----------+----------------------------------------------------------------
y <- |
m | .7237774 .3852893 1.88 0.060 -.0313758 1.478931
x | .5236584 .4351217 1.20 0.229 -.3291644 1.376481
w | .7576026 .3460016 2.19 0.029 .079452 1.435753
wx | -.0034416 .0078974 -0.44 0.663 -.0189201 .012037
mw | -.0077956 .0070744 -1.10 0.270 -.0216612 .00607
_cons | -21.81586 18.84366 -1.16 0.247 -58.74876 15.11704
-------------+----------------------------------------------------------------
var(e.m)| 52.63581 5.263581 43.26744 64.03265
var(e.y)| 48.05594 4.805594 39.50271 58.46113
------------------------------------------------------------------------------
LR test of model vs. saturated: chi2(1) = 696.37, Prob > chi2 = 0.0000
. nlcom (_b[m:x]+($m-$s)*_b[m:wx])*(_b[y:m]+($m-$s)*_b[y:mw]) /* mean - 1 sd */
_nl_1: (_b[m:x]+(52.775-9.47858602138653)*_b[m:wx])*(_b[y:m]+(52.775-9.47858602138653)*_b[y:mw])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1795967 .0621316 2.89 0.004 .057821 .3013723
------------------------------------------------------------------------------
. nlcom (_b[m:x]+($m)*_b[m:wx])*(_b[y:m]+($m)*_b[y:mw]) /* mean */
_nl_1: (_b[m:x]+(52.775)*_b[m:wx])*(_b[y:m]+(52.775)*_b[y:mw])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1585216 .0411369 3.85 0.000 .0778949 .2391484
------------------------------------------------------------------------------
. nlcom (_b[m:x]+($m+$s)*_b[m:wx])*(_b[y:m]+($m+$s)*_b[y:mw]) /* mean + 1 sd */
_nl_1: (_b[m:x]+(52.775+9.47858602138653)*_b[m:wx])*(_b[y:m]+(52.775+9.47858602138653)*_b[y:mw])
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_nl_1 | .1311629 .0538847 2.43 0.015 .0255509 .236775
------------------------------------------------------------------------------
自举法估计结果如下:
capture program drop bootm5
program bootm5, rclass
sem (m <- x w wx)(y <- m x w wx mw)
return scalar cielw = (_b[m:x]+($m-$s)*_b[m:wx])*(_b[y:m]+($m-$s)*_b[y:mw])
return scalar ciemn = (_b[m:x]+($m)*_b[m:wx])*(_b[y:m]+($m)*_b[y:mw])
return scalar ciehi = (_b[m:x]+($m+$s)*_b[m:wx])*(_b[y:m]+($m+$s)*_b[y:mw])
end
. bootstrap r(cielw) r(ciemn) r(ciehi), reps(500) nodots: bootm5
Bootstrap results Number of obs = 200
Replications = 500
command: bootm5
_bs_1: r(cielw)
_bs_2: r(ciemn)
_bs_3: r(ciehi)
------------------------------------------------------------------------------
| Observed Bootstrap Normal-based
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_bs_1 | .1795967 .0731346 2.46 0.014 .0362555 .3229378
_bs_2 | .1585216 .0431536 3.67 0.000 .0739422 .2431011
_bs_3 | .1311629 .0501183 2.62 0.009 .0329329 .229393
------------------------------------------------------------------------------
. estat boot, bc percentile
Bootstrap results Number of obs = 200
Replications = 500
command: bootm5
_bs_1: r(cielw)
_bs_2: r(ciemn)
_bs_3: r(ciehi)
------------------------------------------------------------------------------
| Observed Bootstrap
| Coef. Bias Std. Err. [95% Conf. Interval]
-------------+----------------------------------------------------------------
_bs_1 | .17959665 .004129 .07313458 .0583385 .3322092 (P)
| .0600062 .3465318 (BC)
_bs_2 | .15852165 .0022404 .04315356 .0775977 .247842 (P)
| .0758291 .2446393 (BC)
_bs_3 | .13116295 .0023994 .05011829 .0406206 .2343201 (P)
| .0406206 .2343201 (BC)
------------------------------------------------------------------------------
(P) percentile confidence interval
(BC) bias-corrected confidence interval
写在最后
本文首先详细介绍了中介效应和调节效应的定义,借助 Muller 等人 (2005) 文章中提出的模型详细介绍了中介调节效应和调节中介效应。其次,本文列举了 Preacher (2007) 文章中的五种调节中介效应模型,分别运用基于正态分布假定的基准方法和自举法估计并检验了中介变量所能解释的间接效应幅度如何随调节变量取值的变化而变化。此方法可以广泛应用于微观实证计量研究的机制检验中,相关 Stata 程序包也较为丰富,感兴趣的同学可进一步研究学习。
参考资料
1. Hayes, A.F. (2013) Introduction to Mediation, Moderation, and Conditional Process Analysis: A Regression-Based Approach[M]. New York, NY: Guilford Press
2. Preacher, K.J., Rucker, D.D. and Hayes, A.F. (2007). Addressing moderated mediation hypotheses: Theory, methods, and prescriptions[J]. Multivariate Behavioral Research, 42(1), 185-227. [PDF]
3. Muller D, Judd, Charles M, Yzerbyt, Vincent Y. When moderation is mediated and mediation is moderated[J]. Journal of Personality & Social Psychology, 2005, 89(6):852-863. [PDF]
相关课程
连享会-直播课 上线了! http://lianxh.duanshu.com 免费公开课:
- 直击面板数据模型 - 连玉君,时长:1 小时 40 分钟
- Stata 33 讲 - 连玉君, 每讲 15 分钟.
- 部分直播课 课程资料下载 (PPT,dofiles 等)
课程一览
支持回看,所有课程可以随时购买观看。 连享会 - 文本分析与爬虫 - 专题视频
主讲嘉宾:司继春 || 游万海
连享会 - 效率分析专题 已上线:可随时购买学习+全套课件, 课程主页 已经放置板书和 FAQs
主讲嘉宾:连玉君 | 鲁晓东 | 张宁 课程主页, 微信版 https://gitee.com/arlionn/TE
Note: 部分课程的资料,PPT 等可以前往 连享会-直播课 主页查看,下载。
关于我们
- Stata 连享会 由中山大学连玉君老师团队创办,定期分享实证分析经验。直播间 有很多视频课程,可以随时观看。
- 连享会-主页 和 知乎专栏,300+ 推文,实证分析不再抓狂。
- 公众号推文分类:计量专题 | 分类推文 | 资源工具。推文分成 内生性 | 空间计量 | 时序面板 | 结果输出 | 交乘调节 五类,主流方法介绍一目了然:DID, RDD, IV, GMM, FE, Probit 等。
连享会小程序:扫一扫,看推文,看视频……
扫码加入连享会微信群,提问交流更方便