双重机器学习 中介效应 R语言教程

一、medDML函数

基于Farbmacher等(2022)、张涛和李均超(2023)的研究方法,本文将介绍如何使用R语言进行双重机器学习的中介效应分析,本文示例数据采用的是张涛和李均超(2023)的附件数据。

在双重机器学习中,中介效应的估计方法可以利用R语言的causalweight包中“medDML”函数进行估计,这个函数的解释说明在causalweight包的说明文档中有详细介绍:

medDML(
y,
d,
m,
x,
k = 3,
trim = 0.05,
order = 1,
multmed = TRUE,
fewsplits = FALSE,
normalized = TRUE
)

具体参数的解释如下:

**y**   Dependent variable, must not contain missings.

**d**   Treatment, must be binary (either 1 or 0), must not contain missings.

**m**   Mediator, must not contain missings. May be a scalar or a vector of binary,
categorical, or continuous variables if multmed is TRUE. Must be a binary scalar
if multmed is FALSE.

**x**   (Potential) pre-treatment confounders of the treatment, mediator, and/or
outcome, must not contain missings.

**k**   Number of folds in k-fold cross-fitting if multmed is FALSE. k-1 folds are
 used for estimating the model parameters of the treatment, mediator, and outcome
equations and one fold is used for predicting the efficient score functions. The
roles of the folds are swapped. Default for k is 3. If multmed is TRUE, then
3-fold cross-va
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值