Conditional Average Treatment Effect estimation via Double Machine Learning
cate(
treatment,
response_model,
propensity_model,
contrast = c(1, 0),
data,
nfolds = 5,
type = "dml2",
silent = FALSE,
stratify = FALSE,
mc.cores,
...
)
formula specifying treatment and variables to condition on
formula or ml_model object (formula => glm)
formula or ml_model object (formula => glm)
treatment contrast (default 1 vs 0)
data.frame
Number of folds
'dml1' or 'dml2'
supress all messages and progressbars
If TRUE the response_model will be stratified by treatment
mc.cores Optional number of cores. parallel::mcmapply used instead of future
additional arguments to future.apply::future_mapply
cate.targeted object
sim1 <- function(n=1e4,
seed=NULL,
return_model=FALSE, ...) {
suppressPackageStartupMessages(require("lava"))
if (!is.null(seed)) set.seed(seed)
m <- lava::lvm()
regression(m, ~a) <- function(z1,z2,z3,z4,z5)
cos(z1)+sin(z1*z2)+z3+z4+z5^2
regression(m, ~u) <- function(a,z1,z2,z3,z4,z5)
(z1+z2+z3)*a + z1+z2+z3 + a
distribution(m, ~a) <- binomial.lvm()
if (return_model) return(m)
lava::sim(m, n, p=par)
}
d <- sim1(200)
e <- cate(a ~ z1+z2+z3, response=u~., data=d)
e
#> Estimate Std.Err 2.5% 97.5% P-value
#> (Intercept) 0.6290 0.1592 0.3170 0.9411 7.779e-05
#> z1 0.4525 0.1778 0.1041 0.8010 1.091e-02
#> z2 0.5482 0.1574 0.2397 0.8567 4.956e-04
#> z3 0.7710 0.2121 0.3553 1.1867 2.774e-04