Estimate ATE via Double Machine Learning (Partially Linear Regression)
Source:R/causal.R
morie_estimate_double_ml.RdImplements Chernozhukov et al. (2018) double/debiased machine
learning for the partially linear regression model. When the
DoubleML R package is installed, delegates to
DoubleML::DoubleMLPLR with random-forest nuisance learners.
Otherwise falls back to a hand-rolled cross-fit ridge
implementation: residualise \(Y\) and \(D\) on \(X\) via
K-fold ridge, then regress the outcome residual on the treatment
residual.
Usage
morie_estimate_double_ml(
data,
outcome,
treatment,
covariates,
n_folds = 5L,
n_rep = 1L,
random_state = 42L
)Arguments
- data
A data frame with treatment, outcome, and covariate columns.
- outcome
Name of the continuous outcome column.
- treatment
Name of the (binary) treatment column.
- covariates
Character vector of covariate column names.
- n_folds
Number of cross-fitting folds (default 5).
- n_rep
Number of repeated cross-fitting repetitions (DoubleML only; ignored by the ridge fallback). Default 1.
- random_state
Integer seed for cross-fit folds and learners (default 42).
References
Chernozhukov, V., Chetverikov, D., Demirer, M., Duflo, E., Hansen, C., Newey, W., & Robins, J. (2018). Double/debiased machine learning for treatment and structural parameters. The Econometrics Journal, 21(1), C1–C68.
Examples
set.seed(1)
n <- 200
X <- matrix(rnorm(n * 3), n, 3)
d <- rbinom(n, 1, plogis(X[, 1]))
y <- 0.5 * d + X[, 1] + rnorm(n)
df <- data.frame(y = y, d = d, x1 = X[, 1], x2 = X[, 2], x3 = X[, 3])
morie_estimate_double_ml(df, "y", "d", c("x1", "x2", "x3"))
#> $ate
#> [1] 0.6737756
#>
#> $se
#> [1] 0.1793953
#>
#> $ci_lower
#> [1] 0.3221673
#>
#> $ci_upper
#> [1] 1.025384
#>
#> $n
#> [1] 200
#>
#> $method
#> [1] "PLR (DoubleML)"
#>