查看原文
其他

如何用 Stata 做调节中介效应检验?

Stata连享会 Stata连享会 2020-02-10

作者:崔颖(中央财经大学)          
Source: HOW CAN I DO MODERATED MEDIATION IN STATA? | STATA FAQ

2019暑期“实证研究方法与经典论文”专题班

特别说明

文中包含的链接在微信中无法生效。请点击本文底部左下角的【阅读原文】,转入本文【知乎版】

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)。

若第二步中的 和第三部中的 都是显著的,则调节变量会影响解释变量和中介变量之间的关系 (如图中路径 A)。

若第二步中的 和第三部中的 都是显著的,则调节变量会影响中介变量和被解释变量之间的关系 (如图中路径 B)。

2. 调节中介效应的检验方法

Hayes (2013)  和 Preacher (2007)  详述了调节中介效应的理论背景和框架,他们也提供了检验调节中介效应和计算间接效应大小的方法。

第一种方法是基于正态分布假定的。这种方法理论上很有效,但实际中条件间接效应的分布往往不呈正态,通常会有各异的偏斜和峰态。基于正态分布方法的置信区间和假设检验通常不够准确。第二种方法使用自举法 (Bootstrapping) 获得标准误和置信区间。尽管这种方法的计算速度大大降低,但此时置信区间的计算是修正偏误且非对称的,更好的反映了条件间接效应样本分布的真实情况。

接下来,本文会介绍 Preacher 文章中的五个模型。每个模型都会先使用 semnlcom 命令进行基于正态分布假定的方法估计,然后再介绍如何获得标准误和置信区间的自举估计。

为了计算条件间接效果的大小,我们需要得到以下两个模型的估计系数:模型一用中介变量对解释变量进行回归,模型二用被解释变量对解释变量进行回归。此处,可以使用 Stata 命令 sem 方便得到上述估计系数。条件间接效应可以通过将结构方程模型 (Structural Equation Model) 的估计系数与调节变量给定的取值相乘得到。

对于 Preacher 文章五个模型中的前四个,我们将计算调节变量取三个值 (低 (均值减一个标准差),中 (均值),高 (均值加一个标准差)) 时,分别对应的条件间接效应。其中,模型4 由于涉及到两个调节变量,将会产生 3*3=9 种结果。

2.1 调用数据并定义变量

  1. use "https://stats.idre.ucla.edu/stat/data/hsb2", clear

  2. rename science y // 被解释变量

  3. rename math x // 解释变量

  4. rename read m // 中介变量

  5. rename write w // 调节变量1

  6. rename socst z // 调节变量2

2.2 模型构建与估计

模型 1:解释变量同时也是中介变量与被解释变量之间的调节变量



对模型 1 进行正态分布假定估计:

  1. . summarize x

  2. . global m = r(mean)

  3. . global s = r(sd)

  4. . generate mx = m*x // mv by iv interaction

  5. . sem (m <- x)(y <- m x mx)

输出结果如下:

  1. Endogenous variables

  2. Observed: m y


  3. Exogenous variables

  4. Observed: x mx


  5. Fitting target model:

  6. Iteration 0: log likelihood = -3585.6581

  7. Iteration 1: log likelihood = -3585.6581


  8. Structural equation model Number of obs = 200

  9. Estimation method = ml

  10. Log likelihood = -3585.6581

  11. ------------------------------------------------------------------------------

  12. | OIM

  13. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  14. -------------+----------------------------------------------------------------

  15. Structural |

  16. m |

  17. x | .724807 .0579824 12.50 0.000 .6111636 .8384504

  18. _cons | 14.07254 3.100201 4.54 0.000 7.996255 20.14882

  19. -----------+----------------------------------------------------------------

  20. y |

  21. m | .9766164 .2875081 3.40 0.001 .4131109 1.540122

  22. x | 1.03094 .2969707 3.47 0.001 .4488881 1.612992

  23. mx | -.0115869 .0053091 -2.18 0.029 -.0219926 -.0011812

  24. _cons | -20.83921 15.16952 -1.37 0.170 -50.57092 8.892495

  25. -------------+----------------------------------------------------------------

  26. var(e.m)| 58.71925 5.871925 48.26811 71.43329

  27. var(e.y)| 49.70994 4.970994 40.86232 60.47326

  28. ------------------------------------------------------------------------------

  29. LR test of model vs. saturated: chi2(1) = 594.37, Prob > chi2 = 0.0000

计算特定调节变量取值下的系数:

  1. . nlcom _b[m:x]*(_b[y:m]+($m-$s)*_b[y:mx]) /* mean - 1 sd */


  2. _nl_1: _b[m:x]*(_b[y:m]+(52.645-9.368447794077296)*_b[y:mx])


  3. ------------------------------------------------------------------------------

  4. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  5. -------------+----------------------------------------------------------------

  6. _nl_1 | .3444105 .0656615 5.25 0.000 .2157163 .4731048

  7. ------------------------------------------------------------------------------


  8. . nlcom _b[m:x]*(_b[y:m]+($m)*_b[y:mx]) /* mean */


  9. _nl_1: _b[m:x]*(_b[y:m]+(52.645)*_b[y:mx])


  10. ------------------------------------------------------------------------------

  11. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  12. -------------+----------------------------------------------------------------

  13. _nl_1 | .2657319 .0517277 5.14 0.000 .1643474 .3671164

  14. ------------------------------------------------------------------------------


  15. . nlcom _b[m:x]*(_b[y:m]+($m+$s)*_b[y:mx]) /* mean + 1 sd */


  16. _nl_1: _b[m:x]*(_b[y:m]+(52.645+9.368447794077296)*_b[y:mx])


  17. ------------------------------------------------------------------------------

  18. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  19. -------------+----------------------------------------------------------------

  20. _nl_1 | .1870532 .0609803 3.07 0.002 .067534 .3065724

  21. ------------------------------------------------------------------------------

在此例中,条件间接效应随着调节变量取值的增加而减小。接下来,我们使用如下的bootstrap 命令进行 500 次循环计算。

  1. capture program drop bootm1

  2. program bootm1, rclass

  3. sem (m <- x)(y <- m x mx)

  4. return scalar cielw = _b[m:x]*(_b[y:m]+($m-$s)*_b[y:mx])

  5. return scalar ciemn = _b[m:x]*(_b[y:m]+($m)*_b[y:mx])

  6. return scalar ciehi = _b[m:x]*(_b[y:m]+($m+$s)*_b[y:mx])

  7. end


  8. . bootstrap r(cielw) r(ciemn) r(ciehi), reps(500) nodots: bootm1

结果如下:

  1. Bootstrap results Number of obs = 200

  2. Replications = 500


  3. command: bootm1

  4. _bs_1: r(cielw)

  5. _bs_2: r(ciemn)

  6. _bs_3: r(ciehi)


  7. ------------------------------------------------------------------------------

  8. | Observed Bootstrap Normal-based

  9. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  10. -------------+----------------------------------------------------------------

  11. _bs_1 | .3444105 .0616473 5.59 0.000 .223584 .4652371

  12. _bs_2 | .2657319 .0524074 5.07 0.000 .1630153 .3684484

  13. _bs_3 | .1870532 .0621991 3.01 0.003 .0651451 .3089613

  14. ------------------------------------------------------------------------------

  1. . estat boot, bc percentile


  2. Bootstrap results Number of obs = 200

  3. Replications = 500


  4. command: bootm1

  5. _bs_1: r(cielw)

  6. _bs_2: r(ciemn)

  7. _bs_3: r(ciehi)


  8. ------------------------------------------------------------------------------

  9. | Observed Bootstrap

  10. | Coef. Bias Std. Err. [95% Conf. Interval]

  11. -------------+----------------------------------------------------------------

  12. _bs_1 | .34441055 -.0064576 .06164735 .2203172 .4564181 (P)

  13. | .2290775 .4607842 (BC)

  14. _bs_2 | .26573187 -.0042591 .05240738 .1586023 .3617616 (P)

  15. | .1702687 .3684798 (BC)

  16. _bs_3 | .18705319 -.0020605 .06219915 .0653596 .3086919 (P)

  17. | .0642492 .3030243 (BC)

  18. ------------------------------------------------------------------------------

  19. (P) percentile confidence interval

  20. (BC) bias-corrected confidence interval

模型 2:调节变量影响解释变量与中介变量之间的关系

  1. . summarize w

  2. . global m=r(mean)

  3. . global s=r(sd)

  4. . generate wx=w*x /* moderator 1 by iv interaction */

  5. . sem (m <- x w wx)(y <- m x w wx) // SEM 模型


  6. Endogenous variables

  7. Observed: m y


  8. Exogenous variables

  9. Observed: x w wx


  10. Fitting target model:

  11. Iteration 0: log likelihood = -3919.1644

  12. Iteration 1: log likelihood = -3919.1644


  13. Structural equation model Number of obs = 200

  14. Estimation method = ml

  15. Log likelihood = -3919.1644


  16. ------------------------------------------------------------------------------

  17. | OIM

  18. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  19. -------------+----------------------------------------------------------------

  20. Structural |

  21. m <- |

  22. x | .2707428 .3780083 0.72 0.474 -.4701398 1.011625

  23. w | .1041694 .3417056 0.30 0.760 -.5655613 .7739002

  24. wx | .0044859 .0066954 0.67 0.503 -.0086368 .0176087

  25. _cons | 19.7711 18.53835 1.07 0.286 -16.56341 56.1056

  26. -----------+----------------------------------------------------------------

  27. y <- |

  28. m | .3057916 .0677692 4.51 0.000 .1729665 .4386168

  29. x | .7902703 .3627478 2.18 0.029 .0792976 1.501243

  30. w | .6316515 .3275671 1.93 0.054 -.0103682 1.273671

  31. wx | -.008533 .0064241 -1.33 0.184 -.021124 .0040579

  32. _cons | -14.88752 17.81763 -0.84 0.403 -49.80943 20.03438

  33. -------------+----------------------------------------------------------------

  34. var(e.m)| 52.63581 5.263581 43.26744 64.03265

  35. var(e.y)| 48.3477 4.83477 39.74254 58.81607

  36. ------------------------------------------------------------------------------

  37. LR test of model vs. saturated: chi2(0) = 0.00, Prob > chi2 = .



  38. . nlcom (_b[m:x]+($m-$s)*_b[m:wx])*_b[y:m] /* mean - 1 sd */


  39. _nl_1: (_b[m:x]+(52.775-9.47858602138653)*_b[m:wx])*_b[y:m]


  40. ------------------------------------------------------------------------------

  41. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  42. -------------+----------------------------------------------------------------

  43. _nl_1 | .1421829 .0455118 3.12 0.002 .0529814 .2313843

  44. ------------------------------------------------------------------------------


  45. . nlcom (_b[m:x]+($m)*_b[m:wx])*_b[y:m] /* mean */


  46. _nl_1: (_b[m:x]+(52.775)*_b[m:wx])*_b[y:m]


  47. ------------------------------------------------------------------------------

  48. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  49. -------------+----------------------------------------------------------------

  50. _nl_1 | .1551852 .0408543 3.80 0.000 .0751121 .2352582

  51. ------------------------------------------------------------------------------


  52. . nlcom (_b[m:x]+($m+$s)*_b[m:wx])*_b[y:m] /* mean + 1 sd */


  53. _nl_1: (_b[m:x]+(52.775+9.47858602138653)*_b[m:wx])*_b[y:m]


  54. ------------------------------------------------------------------------------

  55. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  56. -------------+----------------------------------------------------------------

  57. _nl_1 | .1681874 .0451294 3.73 0.000 .0797355 .2566394

  58. ------------------------------------------------------------------------------


  1. capture program drop bootm2

  2. program bootm2, rclass

  3. sem (m <- x w wx)(y <- m x w wx)

  4. return scalar cielw = (_b[m:x]+($m-$s)*_b[m:wx])*_b[y:m]

  5. return scalar ciemn = (_b[m:x]+($m)*_b[m:wx])*_b[y:m]

  6. return scalar ciehi = (_b[m:x]+($m+$s)*_b[m:wx])*_b[y:m]

  7. end


  8. . bootstrap r(cielw) r(ciemn) r(ciehi), reps(500) nodots: bootm2


  9. Bootstrap results Number of obs = 200

  10. Replications = 500


  11. command: bootm2

  12. _bs_1: r(cielw)

  13. _bs_2: r(ciemn)

  14. _bs_3: r(ciehi)


  15. ------------------------------------------------------------------------------

  16. | Observed Bootstrap Normal-based

  17. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  18. -------------+----------------------------------------------------------------

  19. _bs_1 | .1421829 .047612 2.99 0.003 .048865 .2355007

  20. _bs_2 | .1551852 .0409495 3.79 0.000 .0749256 .2354447

  21. _bs_3 | .1681874 .0423557 3.97 0.000 .0851717 .2512031

  22. ------------------------------------------------------------------------------


  23. . estat boot, bc percentile


  24. Bootstrap results Number of obs = 200

  25. Replications = 500


  26. command: bootm2

  27. _bs_1: r(cielw)

  28. _bs_2: r(ciemn)

  29. _bs_3: r(ciehi)


  30. ------------------------------------------------------------------------------

  31. | Observed Bootstrap

  32. | Coef. Bias Std. Err. [95% Conf. Interval]

  33. -------------+----------------------------------------------------------------

  34. _bs_1 | .14218287 .0009392 .04761201 .0579299 .2551758 (P)

  35. | .0579299 .2551758 (BC)

  36. _bs_2 | .15518515 .0001497 .0409495 .078383 .242382 (P)

  37. | .078383 .242382 (BC)

  38. _bs_3 | .16818743 -.0006398 .04235573 .0869211 .2532646 (P)

  39. | .089544 .2589626 (BC)

  40. ------------------------------------------------------------------------------

  41. (P) percentile confidence interval

  42. (BC) bias-corrected confidence interval

在此例中,条件间接效应随着调节变量取值的增加而缓慢增长。

模型 3:调节变量影响中介变量与被解释变量之间的关系

  1. . summarize w

  2. . global m=r(mean)

  3. . global s=r(sd)

  4. . generate mw=m*w /* mv by moderator 1 interaction */

  5. . sem (m <- x)(y <- m x w mw)


  6. Endogenous variables

  7. Observed: m y


  8. Exogenous variables

  9. Observed: x w mw


  10. Fitting target model:

  11. Iteration 0: log likelihood = -4260.6166

  12. Iteration 1: log likelihood = -4260.6166


  13. Structural equation model Number of obs = 200

  14. Estimation method = ml

  15. Log likelihood = -4260.6166


  16. ------------------------------------------------------------------------------

  17. | OIM

  18. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  19. -------------+----------------------------------------------------------------

  20. Structural |

  21. m <- |

  22. x | .724807 .0579824 12.50 0.000 .6111636 .8384504

  23. _cons | 14.07254 3.100201 4.54 0.000 7.996255 20.14882

  24. -----------+----------------------------------------------------------------

  25. y <- |

  26. m | .8193599 .3169173 2.59 0.010 .1982135 1.440506

  27. x | .33696 .0761398 4.43 0.000 .1877287 .4861913

  28. w | .6739726 .2880423 2.34 0.019 .1094201 1.238525

  29. mw | -.0095993 .00574 -1.67 0.094 -.0208495 .0016509

  30. _cons | -17.23954 15.65376 -1.10 0.271 -47.92034 13.44126

  31. -------------+----------------------------------------------------------------

  32. var(e.m)| 58.71925 5.871925 48.26811 71.43329

  33. var(e.y)| 48.10157 4.810157 39.54022 58.51664

  34. ------------------------------------------------------------------------------

  35. LR test of model vs. saturated: chi2(2) = 639.91, Prob > chi2 = 0.0000


  36. . nlcom _b[m:x]*(_b[y:m]+($m-$s)*_b[y:mw]) /* mean - 1 sd */


  37. _nl_1: _b[m:x]*(_b[y:m]+(52.775-9.47858602138653)*_b[y:mw])


  38. ------------------------------------------------------------------------------

  39. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  40. -------------+----------------------------------------------------------------

  41. _nl_1 | .2926372 .0700399 4.18 0.000 .1553616 .4299129

  42. ------------------------------------------------------------------------------


  43. . nlcom _b[m:x]*(_b[y:m]+($m)*_b[y:mw]) /* mean */


  44. _nl_1: _b[m:x]*(_b[y:m]+(52.775)*_b[y:mw])


  45. ------------------------------------------------------------------------------

  46. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  47. -------------+----------------------------------------------------------------

  48. _nl_1 | .2266887 .0524176 4.32 0.000 .1239522 .3294253

  49. ------------------------------------------------------------------------------


  50. . nlcom _b[m:x]*(_b[y:m]+($m+$s)*_b[y:mw]) /* mean + 1 sd */


  51. _nl_1: _b[m:x]*(_b[y:m]+(52.775+9.47858602138653)*_b[y:mw])


  52. ------------------------------------------------------------------------------

  53. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  54. -------------+----------------------------------------------------------------

  55. _nl_1 | .1607402 .0612818 2.62 0.009 .04063 .2808504

  56. ------------------------------------------------------------------------------


在此例中,条件间接效应随着调节变量取值的增加而减少。

  1. capture program drop bootm3

  2. program bootm3, rclass

  3. sem (m <- x)(y <- m x w mw)

  4. return scalar cielw = _b[m:x]*(_b[y:m]+($m-$s)*_b[y:mw])

  5. return scalar ciemn = _b[m:x]*(_b[y:m]+($m)*_b[y:mw])

  6. return scalar ciehi = _b[m:x]*(_b[y:m]+($m+$s)*_b[y:mw])

  7. end


  8. . bootstrap r(cielw) r(ciemn) r(ciehi), reps(500) nodots: bootm3


  9. Bootstrap results Number of obs = 200

  10. Replications = 500


  11. command: bootm3

  12. _bs_1: r(cielw)

  13. _bs_2: r(ciemn)

  14. _bs_3: r(ciehi)


  15. ------------------------------------------------------------------------------

  16. | Observed Bootstrap Normal-based

  17. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  18. -------------+----------------------------------------------------------------

  19. _bs_1 | .2926372 .0666315 4.39 0.000 .1620418 .4232326

  20. _bs_2 | .2266887 .0531356 4.27 0.000 .1225448 .3308326

  21. _bs_3 | .1607402 .0615717 2.61 0.009 .0400619 .2814185

  22. ------------------------------------------------------------------------------


  23. . estat boot, bc percentile


  24. Bootstrap results Number of obs = 200

  25. Replications = 500


  26. command: bootm3

  27. _bs_1: r(cielw)

  28. _bs_2: r(ciemn)

  29. _bs_3: r(ciehi)


  30. ------------------------------------------------------------------------------

  31. | Observed Bootstrap

  32. | Coef. Bias Std. Err. [95% Conf. Interval]

  33. -------------+----------------------------------------------------------------

  34. _bs_1 | .29263724 -.0008677 .06663153 .1549403 .4144395 (P)

  35. | .1554288 .4178429 (BC)

  36. _bs_2 | .22668872 .0000859 .05313561 .1177044 .3335583 (P)

  37. | .1170573 .3309805 (BC)

  38. _bs_3 | .1607402 .0010394 .06157172 .0423122 .2809089 (P)

  39. | .0423122 .2809089 (BC)

  40. ------------------------------------------------------------------------------

  41. (P) percentile confidence interval

  42. (BC) bias-corrected confidence interval

模型 4:两个不同的调节变量,一个影响解释变量与中介变量之间的关系,另一个影响中介变量与被解释变量之间的关系

  1. . summarize w

  2. . global m1 = r(mean)

  3. . global s1 = r(sd)

  4. . summarize z

  5. . global m2 = r(mean)

  6. . global s2 = r(sd)

  7. . capture generate wx=w*x // moderator 1 by iv interaction

  8. . gen mz=m*z // mv by moderator 2 interaction


  9. . sem (m <- x w wx)(y <- m x w wx z mz)


  10. Endogenous variables

  11. Observed: m y


  12. Exogenous variables

  13. Observed: x w wx z mz


  14. Fitting target model:

  15. Iteration 0: log likelihood = -6096.1477

  16. Iteration 1: log likelihood = -6096.1477


  17. Structural equation model Number of obs = 200

  18. Estimation method = ml

  19. Log likelihood = -6096.1477


  20. ------------------------------------------------------------------------------

  21. | OIM

  22. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  23. -------------+----------------------------------------------------------------

  24. Structural |

  25. m <- |

  26. x | .2707428 .3780083 0.72 0.474 -.4701398 1.011625

  27. w | .1041694 .3417056 0.30 0.760 -.5655613 .7739002

  28. wx | .0044859 .0066954 0.67 0.503 -.0086368 .0176087

  29. _cons | 19.7711 18.53835 1.07 0.286 -16.56341 56.1056

  30. -----------+----------------------------------------------------------------

  31. y <- |

  32. m | .4013056 .282893 1.42 0.156 -.1531546 .9557658

  33. x | .7571766 .3864076 1.96 0.050 -.0001684 1.514522

  34. w | .6031543 .3562554 1.69 0.090 -.0950935 1.301402

  35. wx | -.0078215 .0069183 -1.13 0.258 -.021381 .0057381

  36. z | .0553245 .2661857 0.21 0.835 -.4663899 .5770389

  37. mz | -.0015944 .0050813 -0.31 0.754 -.0115536 .0083647

  38. _cons | -17.0724 19.0314 -0.90 0.370 -54.37327 20.22847

  39. -------------+----------------------------------------------------------------

  40. var(e.m)| 52.63581 5.263581 43.26744 64.03265

  41. var(e.y)| 48.28407 4.828407 39.69024 58.73866

  42. ------------------------------------------------------------------------------

  43. LR test of model vs. saturated: chi2(2) = 571.85, Prob > chi2 = 0.0000


  44. . nlcom (_b[m:x]+($m1-$s1)*_b[m:wx])*(_b[y:m]+($m2-$s2)*_b[y:mz]) /* mean1 - 1 sd1; mean2 - 1 sd2 */


  45. _nl_1: (_b[m:x]+(52.775-9.47858602138653)*_b[m:wx])*(_b[y:m]+(52.405-10.7357934642267)*_b[y:mz])


  46. ------------------------------------------------------------------------------

  47. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  48. -------------+----------------------------------------------------------------

  49. _nl_1 | .1557016 .0568792 2.74 0.006 .0442203 .2671828

  50. ------------------------------------------------------------------------------


  51. . nlcom (_b[m:x]+($m1)*_b[m:wx])*(_b[y:m]+($m2-$s2)*_b[y:mz]) /* mean1; mean2 - 1 sd2 */


  52. _nl_1: (_b[m:x]+(52.775)*_b[m:wx])*(_b[y:m]+(52.405-10.7357934642267)*_b[y:mz])



  53. ------------------------------------------------------------------------------

  54. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  55. -------------+----------------------------------------------------------------

  56. _nl_1 | .1699401 .0538198 3.16 0.002 .0644552 .275425

  57. ------------------------------------------------------------------------------


  58. . nlcom (_b[m:x]+($m1+$s1)*_b[m:wx])*(_b[y:m]+($m2-$s2)*_b[y:mz]) /* mean1 + 1 sd1; mean2 - 1 sd2 */


  59. _nl_1: (_b[m:x]+(52.775+9.47858602138653)*_b[m:wx])*(_b[y:m]+(52.405-10.7357934642267)*_b[y:mz])


  60. ------------------------------------------------------------------------------

  61. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  62. -------------+----------------------------------------------------------------

  63. _nl_1 | .1841786 .059107 3.12 0.002 .068331 .3000263

  64. ------------------------------------------------------------------------------


  65. . nlcom (_b[m:x]+($m1-$s1)*_b[m:wx])*(_b[y:m]+($m2)*_b[y:mz]) /* mean1 - 1 sd1; mean2 */


  66. _nl_1: (_b[m:x]+(52.775-9.47858602138653)*_b[m:wx])*(_b[y:m]+(52.405)*_b[y:mz])


  67. ------------------------------------------------------------------------------

  68. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  69. -------------+----------------------------------------------------------------

  70. _nl_1 | .1477424 .04785 3.09 0.002 .0539581 .2415267

  71. ------------------------------------------------------------------------------


  72. nlcom (_b[m:x]+($m1)*_b[m:wx])*(_b[y:m]+($m2)*_b[y:mz]) /* mean1; mean2 */


  73. _nl_1: (_b[m:x]+(52.775)*_b[m:wx])*(_b[y:m]+(52.405)*_b[y:mz])


  74. ------------------------------------------------------------------------------

  75. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  76. -------------+----------------------------------------------------------------

  77. _nl_1 | .1612531 .0431911 3.73 0.000 .0766001 .2459061

  78. ------------------------------------------------------------------------------


  79. . nlcom (_b[m:x]+($m1+$s1)*_b[m:wx])*(_b[y:m]+($m2)*_b[y:mz]) /* mean1 + 1 sd1; mean2 */


  80. _nl_1: (_b[m:x]+(52.775+9.47858602138653)*_b[m:wx])*(_b[y:m]+(52.405)*_b[y:mz])


  81. ------------------------------------------------------------------------------

  82. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  83. -------------+----------------------------------------------------------------

  84. _nl_1 | .1747638 .0476804 3.67 0.000 .081312 .2682156

  85. ------------------------------------------------------------------------------


  86. . nlcom (_b[m:x]+($m1-$s1)*_b[m:wx])*(_b[y:m]+($m2+$s2)*_b[y:mz]) /* mean1 - 1 sd1; mean2 + 1 sd */


  87. _nl_1: (_b[m:x]+(52.775-9.47858602138653)*_b[m:wx])*(_b[y:m]+(52.405+10.73579

  88. > 34642267)*_b[y:mz])


  89. ------------------------------------------------------------------------------

  90. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  91. -------------+----------------------------------------------------------------

  92. _nl_1 | .1397833 .0513566 2.72 0.006 .0391261 .2404404

  93. ------------------------------------------------------------------------------


  94. . nlcom (_b[m:x]+($m1)*_b[m:wx])*(_b[y:m]+($m2+$s2)*_b[y:mz]) /* mean1; mean2 + 1 sd */


  95. _nl_1: (_b[m:x]+(52.775)*_b[m:wx])*(_b[y:m]+(52.405+10.7357934642267)*_b[y:mz])



  96. ------------------------------------------------------------------------------

  97. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  98. -------------+----------------------------------------------------------------

  99. _nl_1 | .1525661 .0486854 3.13 0.002 .0571445 .2479878

  100. ------------------------------------------------------------------------------


  101. . nlcom (_b[m:x]+($m1+$s1)*_b[m:wx])*(_b[y:m]+($m2+$s2)*_b[y:mz]) /* mean1 + 1 sd1; mean2 + 1 sd */


  102. _nl_1: (_b[m:x]+(52.775+9.47858602138653)*_b[m:wx])*(_b[y:m]+(52.405+10.7357934642267)*_b[y:mz])


  103. ------------------------------------------------------------------------------

  104. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  105. -------------+----------------------------------------------------------------

  106. _nl_1 | .165349 .0534577 3.09 0.002 .0605738 .2701241

  107. ------------------------------------------------------------------------------


自举法估计结果如下:

  1. capture program drop bootm4

  2. program bootm4, rclass

  3. sem (m <- x w wx)(y <- m x w wx z mz)

  4. return scalar ciell = (_b[m:x]+($m1-$s1)*_b[m:wx])*(_b[y:m]+($m2-$s2)*_b[y:mz])

  5. return scalar cieml = (_b[m:x]+($m1)*_b[m:wx])*(_b[y:m]+($m2-$s2)*_b[y:mz])

  6. return scalar ciehl = (_b[m:x]+($m1+$s1)*_b[m:wx])*(_b[y:m]+($m2-$s2)*_b[y:mz])

  7. return scalar cielm = (_b[m:x]+($m1-$s1)*_b[m:wx])*(_b[y:m]+($m2)*_b[y:mz])

  8. return scalar ciemm = (_b[m:x]+($m1)*_b[m:wx])*(_b[y:m]+($m2)*_b[y:mz])

  9. return scalar ciehm = (_b[m:x]+($m1+$s1)*_b[m:wx])*(_b[y:m]+($m2)*_b[y:mz])

  10. return scalar cielh = (_b[m:x]+($m1-$s1)*_b[m:wx])*(_b[y:m]+($m2+$s2)*_b[y:mz])

  11. return scalar ciemh = (_b[m:x]+($m1)*_b[m:wx])*(_b[y:m]+($m2+$s2)*_b[y:mz])

  12. return scalar ciehh = (_b[m:x]+($m1+$s1)*_b[m:wx])*(_b[y:m]+($m2+$s2)*_b[y:mz])

  13. end


  14. . bootstrap r(ciell) r(cieml) r(ciehl) r(cielm) r(ciemm) r(ciehm) ///

  15. r(cielh) r(ciemh) r(ciehh), reps(500) nodots: bootm4


  16. Bootstrap results Number of obs = 200

  17. Replications = 500


  18. command: bootm4

  19. _bs_1: r(ciell)

  20. _bs_2: r(cieml)

  21. _bs_3: r(ciehl)

  22. _bs_4: r(cielm)

  23. _bs_5: r(ciemm)

  24. _bs_6: r(ciehm)

  25. _bs_7: r(cielh)

  26. _bs_8: r(ciemh)

  27. _bs_9: r(ciehh)


  28. ------------------------------------------------------------------------------

  29. | Observed Bootstrap Normal-based

  30. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  31. -------------+----------------------------------------------------------------

  32. _bs_1 | .1557016 .0649863 2.40 0.017 .0283307 .2830725

  33. _bs_2 | .1699401 .0621157 2.74 0.006 .0481956 .2916846

  34. _bs_3 | .1841786 .0671694 2.74 0.006 .052529 .3158283

  35. _bs_4 | .1477424 .0487353 3.03 0.002 .0522231 .2432618

  36. _bs_5 | .1612531 .0445524 3.62 0.000 .0739321 .2485741

  37. _bs_6 | .1747638 .0493391 3.54 0.000 .078061 .2714666

  38. _bs_7 | .1397833 .0492498 2.84 0.005 .0432554 .2363111

  39. _bs_8 | .1525661 .0472475 3.23 0.001 .0599627 .2451695

  40. _bs_9 | .165349 .0528395 3.13 0.002 .0617855 .2689124

  41. ------------------------------------------------------------------------------


  42. . estat boot, bc percentile


  43. Bootstrap results Number of obs = 200

  44. Replications = 500


  45. command: bootm4

  46. _bs_1: r(ciell)

  47. _bs_2: r(cieml)

  48. _bs_3: r(ciehl)

  49. _bs_4: r(cielm)

  50. _bs_5: r(ciemm)

  51. _bs_6: r(ciehm)

  52. _bs_7: r(cielh)

  53. _bs_8: r(ciemh)

  54. _bs_9: r(ciehh)


  55. ------------------------------------------------------------------------------

  56. | Observed Bootstrap

  57. | Coef. Bias Std. Err. [95% Conf. Interval]

  58. -------------+----------------------------------------------------------------

  59. _bs_1 | .15570156 -.0011114 .06498635 .0403215 .2988805 (P)

  60. | .0505215 .3103726 (BC)

  61. _bs_2 | .16994009 -.0011208 .06211569 .0493589 .2907081 (P)

  62. | .0592202 .3041216 (BC)

  63. _bs_3 | .18417863 -.0011303 .06716942 .056527 .3229917 (P)

  64. | .0683613 .3390853 (BC)

  65. _bs_4 | .14774241 -.0025282 .04873525 .0589332 .2458749 (P)

  66. | .0740234 .2873931 (BC)

  67. _bs_5 | .1612531 -.002414 .04455236 .0787119 .2513106 (P)

  68. | .0928683 .2640307 (BC)

  69. _bs_6 | .17476379 -.0022999 .04933908 .0872108 .2716488 (P)

  70. | .0949407 .2876344 (BC)

  71. _bs_7 | .13978326 -.0039449 .04924982 .0522442 .2376913 (P)

  72. | .0635381 .2752829 (BC)

  73. _bs_8 | .15256611 -.0037072 .04724748 .0625553 .2519639 (P)

  74. | .0673052 .2589675 (BC)

  75. _bs_9 | .16534895 -.0034695 .05283947 .0625117 .2702666 (P)

  76. | .0756997 .2865739 (BC)

  77. ------------------------------------------------------------------------------

  78. (P) percentile confidence interval

  79. (BC) bias-corrected confidence interval

模型 5:一个调节变量同时影响解释变量与中介变量之间的关系及中介变量与被解释变量之间的关系

  1. . summarize w

  2. . global m = r(mean)

  3. . global s = r(sd)

  4. . capture generate wx = w*x // moderator 1 by iv interaction

  5. . capture generate mw = m*w // mv by moderator 1 interaction


  6. . sem (m <- x w wx)(y <- m x w wx mw)


  7. Endogenous variables

  8. Observed: m y


  9. Exogenous variables

  10. Observed: x w wx mw


  11. Fitting target model:

  12. Iteration 0: log likelihood = -5398.1882

  13. Iteration 1: log likelihood = -5398.1882


  14. Structural equation model Number of obs = 200

  15. Estimation method = ml

  16. Log likelihood = -5398.1882


  17. ------------------------------------------------------------------------------

  18. | OIM

  19. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  20. -------------+----------------------------------------------------------------

  21. Structural |

  22. m <- |

  23. x | .2707428 .3780083 0.72 0.474 -.4701398 1.011625

  24. w | .1041694 .3417056 0.30 0.760 -.5655613 .7739002

  25. wx | .0044859 .0066954 0.67 0.503 -.0086368 .0176087

  26. _cons | 19.7711 18.53835 1.07 0.286 -16.56341 56.1056

  27. -----------+----------------------------------------------------------------

  28. y <- |

  29. m | .7237774 .3852893 1.88 0.060 -.0313758 1.478931

  30. x | .5236584 .4351217 1.20 0.229 -.3291644 1.376481

  31. w | .7576026 .3460016 2.19 0.029 .079452 1.435753

  32. wx | -.0034416 .0078974 -0.44 0.663 -.0189201 .012037

  33. mw | -.0077956 .0070744 -1.10 0.270 -.0216612 .00607

  34. _cons | -21.81586 18.84366 -1.16 0.247 -58.74876 15.11704

  35. -------------+----------------------------------------------------------------

  36. var(e.m)| 52.63581 5.263581 43.26744 64.03265

  37. var(e.y)| 48.05594 4.805594 39.50271 58.46113

  38. ------------------------------------------------------------------------------

  39. LR test of model vs. saturated: chi2(1) = 696.37, Prob > chi2 = 0.0000


  40. . nlcom (_b[m:x]+($m-$s)*_b[m:wx])*(_b[y:m]+($m-$s)*_b[y:mw]) /* mean - 1 sd */


  41. _nl_1: (_b[m:x]+(52.775-9.47858602138653)*_b[m:wx])*(_b[y:m]+(52.775-9.47858602138653)*_b[y:mw])


  42. ------------------------------------------------------------------------------

  43. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  44. -------------+----------------------------------------------------------------

  45. _nl_1 | .1795967 .0621316 2.89 0.004 .057821 .3013723

  46. ------------------------------------------------------------------------------


  47. . nlcom (_b[m:x]+($m)*_b[m:wx])*(_b[y:m]+($m)*_b[y:mw]) /* mean */


  48. _nl_1: (_b[m:x]+(52.775)*_b[m:wx])*(_b[y:m]+(52.775)*_b[y:mw])


  49. ------------------------------------------------------------------------------

  50. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  51. -------------+----------------------------------------------------------------

  52. _nl_1 | .1585216 .0411369 3.85 0.000 .0778949 .2391484

  53. ------------------------------------------------------------------------------


  54. . nlcom (_b[m:x]+($m+$s)*_b[m:wx])*(_b[y:m]+($m+$s)*_b[y:mw]) /* mean + 1 sd */


  55. _nl_1: (_b[m:x]+(52.775+9.47858602138653)*_b[m:wx])*(_b[y:m]+(52.775+9.47858602138653)*_b[y:mw])



  56. ------------------------------------------------------------------------------

  57. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  58. -------------+----------------------------------------------------------------

  59. _nl_1 | .1311629 .0538847 2.43 0.015 .0255509 .236775

  60. ------------------------------------------------------------------------------


自举法估计结果如下:

  1. capture program drop bootm5

  2. program bootm5, rclass

  3. sem (m <- x w wx)(y <- m x w wx mw)

  4. return scalar cielw = (_b[m:x]+($m-$s)*_b[m:wx])*(_b[y:m]+($m-$s)*_b[y:mw])

  5. return scalar ciemn = (_b[m:x]+($m)*_b[m:wx])*(_b[y:m]+($m)*_b[y:mw])

  6. return scalar ciehi = (_b[m:x]+($m+$s)*_b[m:wx])*(_b[y:m]+($m+$s)*_b[y:mw])

  7. end


  8. . bootstrap r(cielw) r(ciemn) r(ciehi), reps(500) nodots: bootm5


  9. Bootstrap results Number of obs = 200

  10. Replications = 500


  11. command: bootm5

  12. _bs_1: r(cielw)

  13. _bs_2: r(ciemn)

  14. _bs_3: r(ciehi)


  15. ------------------------------------------------------------------------------

  16. | Observed Bootstrap Normal-based

  17. | Coef. Std. Err. z P>|z| [95% Conf. Interval]

  18. -------------+----------------------------------------------------------------

  19. _bs_1 | .1795967 .0731346 2.46 0.014 .0362555 .3229378

  20. _bs_2 | .1585216 .0431536 3.67 0.000 .0739422 .2431011

  21. _bs_3 | .1311629 .0501183 2.62 0.009 .0329329 .229393

  22. ------------------------------------------------------------------------------


  23. . estat boot, bc percentile


  24. Bootstrap results Number of obs = 200

  25. Replications = 500


  26. command: bootm5

  27. _bs_1: r(cielw)

  28. _bs_2: r(ciemn)

  29. _bs_3: r(ciehi)


  30. ------------------------------------------------------------------------------

  31. | Observed Bootstrap

  32. | Coef. Bias Std. Err. [95% Conf. Interval]

  33. -------------+----------------------------------------------------------------

  34. _bs_1 | .17959665 .004129 .07313458 .0583385 .3322092 (P)

  35. | .0600062 .3465318 (BC)

  36. _bs_2 | .15852165 .0022404 .04315356 .0775977 .247842 (P)

  37. | .0758291 .2446393 (BC)

  38. _bs_3 | .13116295 .0023994 .05011829 .0406206 .2343201 (P)

  39. | .0406206 .2343201 (BC)

  40. ------------------------------------------------------------------------------

  41. (P) percentile confidence interval

  42. (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]

 

关于我们

  • Stata 连享会(公众号:StataChina)】由中山大学连玉君老师团队创办,旨在定期与大家分享 Stata 应用的各种经验和技巧。

  • 公众号推文同步发布于 CSDN-Stata连享会 、简书-Stata连享会 和 知乎-连玉君Stata专栏。可以在上述网站中搜索关键词StataStata连享会后关注我们。

  • 点击推文底部【阅读原文】可以查看推文中的链接并下载相关资料。

  • Stata连享会 精彩推文1  || 精彩推文2

联系我们

  • 欢迎赐稿: 欢迎将您的文章或笔记投稿至Stata连享会(公众号: StataChina),我们会保留您的署名;录用稿件达五篇以上,即可免费获得 Stata 现场培训 (初级或高级选其一) 资格。

  • 意见和资料: 欢迎您的宝贵意见,您也可以来信索取推文中提及的程序和数据。

  • 招募英才: 欢迎加入我们的团队,一起学习 Stata。合作编辑或撰写稿件五篇以上,即可免费获得 Stata 现场培训 (初级或高级选其一) 资格。

  • 联系邮件: StataChina@163.com

往期精彩推文



欢迎加入Stata连享会(公众号: StataChina)

    您可能也对以下帖子感兴趣

    文章有问题?点此查看未经处理的缓存