打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
med4way:中介效应和交互效应分析

🍎 连享会主页:lianxh.cn

🎦 论文班·精讲8篇论文
📅 2021 年 5.2-4 日
🔑 主讲:梁平汉(中山大学);张川川 (浙江大学);连玉君 (中山大学)
🍓 课程主页https://gitee.com/lianxh/TE, 诚邀助教6名

New! lianxh 命令发布了:   GIF 动图介绍
随时搜索 Stata 推文、教程、手册、论坛,安装命令如下:
. ssc install lianxh

作者: 曹琳君 (南开大学)
邮箱: jilyo@stu.xmu.edu.cn & 1072759894@qq.com


目录

  • 1. 背景介绍

  • 2. med4way 命令介绍

    • 2.1 理论部分

    • 2.2 安装和语法结构

  • 3. Stata 实例

  • 4. 结语

  • 5. 参考资料

  • 6. 相关推文


1. 背景介绍

中介分析是阐明 X 和 Y 如何关联的重要机制之一。在连享会以往的推文中,我们介绍了传统的中介效应分析方法(具体链接见相关推文部分),包括逐步检验回归系数法、系数乘积检验法和系数差异检验法。

然而,在使用传统的中介效应分析时,研究者也面临下列问题:(1)如果没有对中介-结果混杂因素 (mediator-outcome confounders)进行控制,那么传统的中介方法产生的结果可能有很大的偏差 (Andrea Bellavia, 2021)。(2)传统的中介分析没有包含 的交互作用 (exposure-mediator interaction)。如果交互作用确实存在且被忽视,直接和间接的影响就会有偏差 (Andrea Bellavia, 2021)。(3)传统的中介分析主要适用于 是连续变量且影响是线性的情况。对于非线性的影响,用传统的中介分析方法分析并不容易 (Andrea Bellavia, 2021)。

因此,能够解决上述问题的因果中介分析方法逐渐受到研究者的重视。在下文中,作者主要向大家介绍一种可以同时分析中介效应 (M)和 交互效应 (X-M)的因果中介分析命令 med4way

对因果中介分析背景有更多兴趣的研究者也可以点击下方的参考链接。参考链接:Mediation and interaction analysis

温馨提示: 文中链接在微信中无法生效。请点击底部「阅读原文」

2. med4way 命令介绍

2.1 理论部分

如下图所示,包含 交互作用的因果中介分析将 的影响(总体效应)分为四个效应:纯间接效应或被调节的主效应  (pure natural indirect effect  or mediated main effect),参照交互效应 (reference interaction),被调节的交互效应 (mediated interaction) 和被控制的直接效应 (Controlled direct effect)。

在表中 是结果变量 是暴漏因素也就是我们常说的 , 是潜在中介变量。 表示当暴漏因素 处于 a 水平且潜在的中介变量 处于 m 水平时, 的取值。

2.2 安装和语法结构

med4way命令是 Andrea Discacciati, Andrea Bellavia, Jane J Lee, Maitreyi Mazumdar &  Linda Valeri (2018) 根据上述表格所编写的 Stata 新命令。

安装和数据下载有两种途径:

(1) 从作者的 github 主页下载:

. net install med4way, from('https://raw.githubusercontent.com/anddis/med4way/master/') replace

*-下载范例数据
. net get med4way, from('https://raw.githubusercontent.com/anddis/med4way/master/')

(2) 从连享会主页下载:

*-安装程序文件
. net install med4way , from(https://file.lianxh.cn/StataCMD/med4way)
*-下载附带数据
. net get med4way , from(https://file.lianxh.cn/StataCMD/med4way)

语法结构如下:

. help med4way

. med4way depavr varlist [if] [in],
a0(real) a1(real) m(real) yreg(string) mreg(string)
  • depvar:被解释变量;
  • varlist:依次为暴露因素、中介变量 、多个混杂因素(可有可无,视情况而定);
  • a0(real):real 表示暴露因素的参考维度 (the referent level of the exposure);假设暴露因素 表示是否吸烟, 表示不吸烟,那么 0 就是参考维度。
  • a1(real):real 表示暴露因素的真实维度 (the actual level of the exposure);假设暴露因素 表示是否吸烟,暴露因素 表示吸烟,那么1就是真实维度。
  • m(real):real 表示中介变量的维度 (the level of the mediator);
  • yreg(string):string 表示为结果指定的回归模型形式 (the form of the regression model for the outcome);
  • mreg(string):string 表示为中介指定的回归模型形式 (the form of the regression model for the mediator )。

3. Stata 实例

下面我们用一个 med4way 命令的模拟数据集 med4way_example_1.dta 进行演示。在该数据集中结果变量和中介变量都是二元变量。

. net get med4way , from(https://file.lianxh.cn/StataCMD/med4way)
. use med4way_example_1.dta

. med4way y_bin treat m_bin cvar1 cvar2 cvar3, ///
a0(0) a1(1) m(0) ///
yreg (logistic) mreg(logistic)

/* Notes:

y_bin:因变量
treat:暴露因素
m_bin:中介变量
cvar1:混杂因素1
cvar2:混杂因素2
cvars:混杂因素3
*/

模型的运行结果如下:

Summary

Outcome (yvar): y_bin
Exposure (avar): treat
Mediator (mvar): m_bin
Covariates (cvars): cvar1 cvar2 cvar3

Model for the outcome (yreg): logistic
Model for the mediator (mreg): logistic

Referent exposure level (a0): 0
Actual exposure level (a1): 1
Mediator level for the decomposition (m): 0
Fixed values of the covariates (c): .577 .319 62.26


-> Model for the outcome

Iteration 0: log likelihood = -690.9676
Iteration 1: log likelihood = -589.56724
Iteration 2: log likelihood = -589.33454
Iteration 3: log likelihood = -589.33446
Iteration 4: log likelihood = -589.33446

Logistic regression Number of obs = 1,000
LR chi2(6) = 203.27
Prob > chi2 = 0.0000
Log likelihood = -589.33446 Pseudo R2 = 0.1471

----------------------------------------------------------------------------------
y_bin | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-----------------+----------------------------------------------------------------
treat | -.2944844 .289416 -1.02 0.309 -.8617292 .2727605
m_bin | 1.046198 .2400432 4.36 0.000 .5757223 1.516674
_treatXm_bin_000 | .9821457 .3321434 2.96 0.003 .3311566 1.633135
cvar1 | .1219094 .1451617 0.84 0.401 -.1626023 .4064212
cvar2 | .1908434 .158203 1.21 0.228 -.1192287 .5009155
cvar3 | .0451507 .0065279 6.92 0.000 .0323562 .0579451
_cons | -3.823604 .4667596 -8.19 0.000 -4.738436 -2.908772
----------------------------------------------------------------------------------


-> Model for the mediator

Iteration 0: log likelihood = -588.16878
Iteration 1: log likelihood = -555.60573
Iteration 2: log likelihood = -555.11944
Iteration 3: log likelihood = -555.11923
Iteration 4: log likelihood = -555.11923

Logistic regression Number of obs = 1,000
LR chi2(4) = 66.10
Prob > chi2 = 0.0000
Log likelihood = -555.11923 Pseudo R2 = 0.0562

------------------------------------------------------------------------------
m_bin | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
treat | .2400897 .1477509 1.62 0.104 -.0494968 .5296762
cvar1 | .3107653 .1491474 2.08 0.037 .0184418 .6030888
cvar2 | -.5623266 .154374 -3.64 0.000 -.8648942 -.259759
cvar3 | .0335621 .0065424 5.13 0.000 .0207393 .0463849
_cons | -1.188081 .4246957 -2.80 0.005 -2.02047 -.3556931
------------------------------------------------------------------------------


-> 4-way decomposition: delta method

------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
tereri | .9330728 .2970645 3.14 0.002 .350837 1.515309
ereri_cde | -.1102571 .108841 -1.01 0.311 -.3235814 .1030673
ereri_intref | .9440357 .28698 3.29 0.001 .3815654 1.506506
ereri_intmed | .0620038 .0435735 1.42 0.155 -.0233986 .1474062
ereri_pie | .0372904 .0243739 1.53 0.126 -.0104815 .0850623
------------------------------------------------------------------------------
tereri=total excess relative risk; ereri_cde=excess relative risk due to controlled direct effect; ereri_intref=excess relative risk due to
reference interaction; ereri_intmed=excess relative risk due to mediated interaction; ereri_pie=excess relative risk due to pure indirect effect.


模型1是各因素对 因变量 的回归,模型2是各因素对中介变量 的回归。最后一张表是总效应的分解结果。

4. 结语

关于 med4way 的基本介绍在这里就结束了,想要深入了解的学者也可以阅读下方的参考资料。由于地址限制,如果文中提供的下载方式无法奏效,大家可以直接访问如下码云仓库,手动下载相关命令和数据文件。方法为:点击【克隆/下载】,下载仓库的 zip 文件,解压后放置为 D:\med4way ,在 Stata 命令窗口执行 net install med4way, from(D:\med4way) 即可安装。

  • https://gitee.com/caolinjun/med4way,或
  • https://gitee.com/arlionn/med4way。

5. 参考资料

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
xtheckmanfe:面板Heckman模型的固定效应估计
Stata:空间DID操作及应用手册(数据、代码)
Stata估算观测数据的风险比
互助问答第194期:面板固定效应回归问题
R数据分析:有调节的中介
期货套期保值的VaR与CVaR
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服