📦 💉 R/txshift: Targeted Learning of the Causal Effects of Stochastic Interventions under Two-Phase Sampling
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
R
docs
man
tests
vignettes
.Rbuildignore
.gitignore
.travis.yml
CONTRIBUTING.md
DESCRIPTION
LICENSE
Makefile
NAMESPACE
NEWS.md
README-refs.bib
README.Rmd
README.md
_pkgdown.yml
appveyor.yml
codecov.yml
txshift.Rproj

README.md

R/txshift

Travis-CI Build Status AppVeyor Build Status Coverage Status Project Status: Active – The project has reached a stable, usable state and is being actively developed. MIT license

Targeted Learning of the Causal Effects of Stochastic Interventions

Authors: Nima Hejazi and David Benkeser


What’s txshift?

The txshift R package is designed to provide facilities to compute targeted maximum likelihood estimates (TMLE) of the population-level causal effect of interventions based on stochastic mechanisms for treatment assignment (Díaz and van der Laan (2012)). As opposed to the original algorithm given for computing such a TMLE, txshift implements and builds upon subsequent work by Díaz and van der Laan (2018), who reveal a simplified algorithm for computing the TML estimator of the shift intervention causal effect parameter.

For many practical applications (e.g., observational medical studies), it is often the case that the data structure of interest is generated by a selective sampling process (i.e., a two-stage design). In such cases, TML estimators may be augmented to cope with – and even exhibit efficiency – in spite of the challenges induced by such an artificial censoring process. This augmentation procedure is done by way of adding inverse probability of censoring weights (IPCW), which leads to an IPCW-TMLE, originally proposed by Rose and van der Laan (2011). txshift extends the approach of computing IPCW-TMLEs to the shift intervention causal effect parameter.

For background on the Targeted Learning methodology, as well as recent advances, the canonical references are van der Laan and Rose (2011) and van der Laan and Rose (2018).


Installation

Install the most recent stable release from GitHub via devtools:

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

Example

To illustrate how txshift may be used to ascertain the effect of a treatment, consider the following example:

library(txshift)
library(condensier)
set.seed(429153)

# simulate simple data for tmle-shift sketch
n_obs <- 1000  # number of observations
n_w <- 1  # number of baseline covariates
p_w <- 0.5  # probability of a success ("1") in the baseline variables
tx_mult <- 2  # multiplier for the effect of W = 1 on the treatment

## baseline covariate -- simple, binary
W <- as.numeric(replicate(n_w, rbinom(n_obs, 1, p_w)))

## create treatment based on baseline W
A <- as.numeric(rnorm(n_obs, mean = tx_mult * W, sd = 1))

# create outcome as a linear function of A, W + white noise
Y <- A + W + rnorm(n_obs, mean = 0, sd = 1)

# fit the TMLE
tmle_shift <- tmle_txshift(W = W, A = A, Y = Y, delta = 0.5,
                           g_fit_args = list(fit_type = "glm",
                                             nbins = 25,
                                             bin_method = "dhist",
                                             bin_estimator =
                                               speedglmR6$new(),
                                             parfit = FALSE),
                           Q_fit_args = list(fit_type = "glm",
                                             glm_formula = "Y ~ .")
                          )

# conveniently summarize the results
summary(tmle_shift)
#>       lwr_ci    param_est       upr_ci    param_var     eif_mean 
#>     1.957777     2.098018     2.238259      0.00512 3.961214e-12 
#>       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:
ipcwtmle_shift <- tmle_txshift(W = W, A = A, Y = Y, delta = 0.5,
                               C = C, V = c("W", "Y"),
                               max_iter = 10,  # limit iterations for speed
                               ipcw_fit_args = list(fit_type = "glm"),
                               g_fit_args = list(fit_type = "glm",
                                                 nbins = 25,
                                                 bin_method = "dhist",
                                                 bin_estimator =
                                                   speedglmR6$new(),
                                                 parfit = FALSE),
                               Q_fit_args = list(fit_type = "glm",
                                                 glm_formula = "Y ~ ."),
                               eif_reg_spec = FALSE  # fit EIF with a GLM
                              )

# conveniently summarize the results
summary(ipcwtmle_shift)
#>       lwr_ci    param_est       upr_ci    param_var     eif_mean 
#>     1.693336     2.121628     2.549921     0.047751 2.161841e-08 
#>       n_iter 
#>           10

Issues

If you encounter any bugs or have any specific feature requests, please file an issue.


Contributions

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


Citation

After using the txshift R package, please cite the following:

    @manual{hejazi2018txshift,
      author = {Hejazi, Nima S and {van der Laan}, Mark J and Benkeser,
        David C},
      title = {txshift: {Targeted Learning} of the Causal Effects of
        Stochastic Interventions in {R}},
      year  = {2018},
      url = {https://github.com/nhejazi/txshift},
      note = {R package version 0.2.0}
    }

Related

  • R/tmle3shift - An R package providing an independent implementation of the same core routines for the TML estimation procedure and statistical methodology as is made available here, through reliance on a unified interface for Targeted Learning provided by the tmle3 engine of the tlverse ecosystem.

Funding

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


License

© 2017-2018 Nima S. Hejazi

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

MIT License

Copyright (c) 2017-2018 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.

References

Díaz, Iván, and Mark J van der Laan. 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.

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.

van der Laan, Mark J, and Sherri Rose. 2011. Targeted Learning: Causal Inference for Observational and Experimental Data. Springer Science & Business Media.

———. 2018. Targeted Learning in Data Science: Causal Inference for Complex Longitudinal Studies. Springer Science & Business Media.