Targeted Learning of the Causal Effects of Stochastic Interventions

**Authors:** Nima Hejazi and David Benkeser

`txshift`

?The `txshift`

R package is designed to compute semiparametric-efficient estimates of the counterfactual mean of an outcome under stochastic mechanisms for treatment assignment and causal quantities defined through such quantities (Díaz and van der Laan 2012). In particular, `txshift`

implements and builds upon a simplified algorithm for the targeted maximum likelihood (TML) estimator of such a counterfactual mean, originally proposed in Díaz and van der Laan (2018), and uses the same machinery to compute a one-step estimator (Pfanzagl and Wefelmeyer 1985).

For many practical applications (e.g., vaccine efficacy trials), it is often the case that the observed data structure is generated under a two-phase sampling mechanism (i.e., through the use of a two-stage design). In such cases, semiparametric-efficient estimators (both of both the TML and one-step varieties) must be augmented to exhibit efficiency in spite of the challenges induced by the sampling process. An appropriate augmentation procedure was given by Rose and van der Laan (2011), who proposed the use of inverse probability of censoring weights (IPCW) alongside an augmentation of the efficient influence function. `txshift`

extends this approach to computing IPC-weighted one-step and TML estimators of the counterfactual mean under a stochastic treatment regime.

Install the most recent *stable release* from GitHub via `devtools`

:

`devtools::install_github("nhejazi/txshift", build_vignettes = FALSE)`

To illustrate how `txshift`

may be used to ascertain the effect of a treatment, consider the following example:

```
library(txshift)
library(haldensify)
set.seed(429153)
# simulate simple data
n_obs <- 1000
W <- replicate(2, rbinom(n_obs, 1, 0.5))
A <- rnorm(n_obs, mean = 2 * W, sd = 1)
Y <- rbinom(n_obs, 1, plogis(A + W + rnorm(n_obs, mean = 0, sd = 1)))
# fit the TMLE
tmle <- txshift(W = W, A = A, Y = Y, delta = 0.5,
estimator = "tmle",
g_fit_args = list(fit_type = "hal",
n_bins = 5,
grid_type = "equal_mass",
lambda_seq = exp(seq(-1, -9, length = 300))),
Q_fit_args = list(fit_type = "glm",
glm_formula = "Y ~ .")
)
summary(tmle)
#> lwr_ci param_est upr_ci param_var eif_mean estimator
#> 0.7474 0.7783 0.8063 2e-04 8.1032e-10 tmle
#> n_iter
#> 0
# fit a one-step estimator for comparison
os <- txshift(W = W, A = A, Y = Y, delta = 0.5,
estimator = "onestep",
g_fit_args = list(fit_type = "hal",
n_bins = 5,
grid_type = "equal_mass",
lambda_seq = exp(seq(-1, -9, length = 300))),
Q_fit_args = list(fit_type = "glm",
glm_formula = "Y ~ .")
)
summary(os)
#> lwr_ci param_est upr_ci param_var eif_mean estimator
#> 0.7472 0.7779 0.8059 2e-04 -1.6543e-03 onestep
#> n_iter
#> 0
# now, let's introduce a censoring process (for two-stage sampling)
C <- rbinom(n_obs, 1, plogis(W + Y))
# fit an IPCW-TMLE to account for this censoring process:
ipcw_tmle <- txshift(W = W, A = A, Y = Y, delta = 0.5,
C = C, V = c("W", "Y"),
estimator = "tmle",
max_iter = 5,
ipcw_fit_args = list(fit_type = "glm"),
g_fit_args = list(fit_type = "hal",
n_bins = 5,
grid_type = "equal_mass",
lambda_seq =
exp(seq(-1, -9, length = 300))),
Q_fit_args = list(fit_type = "glm",
glm_formula = "Y ~ ."),
eif_reg_type = "glm"
)
summary(ipcw_tmle)
#> lwr_ci param_est upr_ci param_var eif_mean estimator
#> 0.7566 0.7921 0.8237 3e-04 -4.7687e-06 tmle
#> n_iter
#> 1
# compare with an IPCW-agumented one-step estimator under censoring:
ipcw_os <- txshift(W = W, A = A, Y = Y, delta = 0.5,
C = C, V = c("W", "Y"),
estimator = "onestep",
ipcw_efficiency = FALSE,
ipcw_fit_args = list(fit_type = "glm"),
g_fit_args = list(fit_type = "hal",
n_bins = 5,
grid_type = "equal_mass",
lambda_seq =
exp(seq(-1, -9, length = 300))),
Q_fit_args = list(fit_type = "glm",
glm_formula = "Y ~ ."),
eif_reg_type = "glm"
)
summary(ipcw_os)
#> lwr_ci param_est upr_ci param_var eif_mean estimator
#> 0.7481 0.794 0.8334 5e-04 1.0652e-02 onestep
#> n_iter
#> 0
```

Contributions are very welcome. Interested contributors should consult our contribution guidelines prior to submitting a pull request.

After using the `txshift`

R package, please cite the following:

```
@manual{hejazi2019txshift,
author = {Hejazi, Nima S and Benkeser, David C},
title = {txshift: {Targeted Learning} of the Causal Effects of
Stochastic Interventions in {R}},
year = {2019},
url = {https://github.com/nhejazi/txshift},
note = {R package version 0.2.4}
}
```

The development of this software was supported in part through a grant from the National Institutes of Health: T32 LM012417-02.

© 2017-2019 Nima S. Hejazi

The contents of this repository are distributed under the MIT license. See below for details:

```
MIT License
Copyright (c) 2017-2019 Nima S. Hejazi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```

Díaz, Iván, and Nima S Hejazi. 2019. “Causal Mediation Analysis for Stochastic Interventions.” *Submitted*. https://arxiv.org/abs/1901.02776.

Díaz, Iván, and Mark J van der Laan. 2011. “Super Learner Based Conditional Density Estimation with Application to Marginal Structural Models.” *The International Journal of Biostatistics* 7 (1). De Gruyter: 1–20.

———. 2012. “Population Intervention Causal Effects Based on Stochastic Interventions.” *Biometrics* 68 (2). Wiley Online Library: 541–49.

———. 2018. “Stochastic Treatment Regimes.” In *Targeted Learning in Data Science: Causal Inference for Complex Longitudinal Studies*, 167–80. Springer Science & Business Media.

Pfanzagl, J, and W Wefelmeyer. 1985. “Contributions to a General Asymptotic Statistical Theory.” *Statistics & Risk Modeling* 3 (3-4). OLDENBOURG WISSENSCHAFTSVERLAG: 379–88.

Rose, Sherri, and Mark J van der Laan. 2011. “A Targeted Maximum Likelihood Estimator for Two-Stage Designs.” *The International Journal of Biostatistics* 7 (1): 1–21.