项目作者: nhejazi

项目描述 :
:package: :game_die: R/medshift: Causal Mediation Analysis for Stochastic Interventions
高级语言: R
项目地址: git://github.com/nhejazi/medshift.git
创建时间: 2018-08-28T21:14:49Z
项目社区:https://github.com/nhejazi/medshift

开源协议:Other

下载


R/medshift

R-CMD-check
Coverage
Status
Project Status: Active – The project has reached a stable, usable
state and is being actively
developed.
MIT
license

Causal Mediation Analysis for Stochastic Interventions

Authors: Nima Hejazi and Iván
Díaz


What’s medshift?

The medshift R package is designed to provide facilities for
estimating a parameter that arises in a decomposition of the population
intervention causal effect into the (in)direct effects under stochastic
interventions in the setting of mediation analysis. medshift is
designed as an implementation to accompany the methodology described in
Dı́az and Hejazi (2020). Implemented estimators include the classical
substitution (G-computation) estimator, an inverse probability weighted
(IPW) estimator, an efficient one-step estimator using cross-fitting
(Pfanzagl and Wefelmeyer 1985; Zheng and van der Laan 2011; Chernozhukov
et al. 2018), and a cross-validated targeted minimum loss (TML)
estimator (van der Laan and Rose 2011; Zheng and van der Laan 2011).
medshift integrates with the sl3 R
package
(Coyle et al. 2022) to allow
constructed estimators to leverage machine learning for nuisance
estimation.


Installation

Install the most recent version from the master branch on GitHub via
remotes:

  1. remotes::install_github("nhejazi/medshift")

Example

To illustrate how medshift may be used to estimate the effect of
applying a stochastic intervention to the treatment (A) while keeping
the mediator(s) (Z) fixed, consider the following example:

  1. library(data.table)
  2. library(medshift)
  3. # produces a simple data set based on ca causal model with mediation
  4. make_simple_mediation_data <- function(n_obs = 1000) {
  5. # baseline covariate -- simple, binary
  6. W <- rbinom(n_obs, 1, prob = 0.50)
  7. # create treatment based on baseline W
  8. A <- as.numeric(rbinom(n_obs, 1, prob = W / 4 + 0.1))
  9. # single mediator to affect the outcome
  10. z1_prob <- 1 - plogis((A^2 + W) / (A + W^3 + 0.5))
  11. Z <- rbinom(n_obs, 1, prob = z1_prob)
  12. # create outcome as a linear function of A, W + white noise
  13. Y <- Z + A - 0.1 * W + rnorm(n_obs, mean = 0, sd = 0.25)
  14. # full data structure
  15. data <- as.data.table(cbind(Y, Z, A, W))
  16. setnames(data, c("Y", "Z", "A", "W"))
  17. return(data)
  18. }
  19. # set seed and simulate example data
  20. set.seed(75681)
  21. example_data <- make_simple_mediation_data()
  22. # compute one-step estimate for an incremental propensity score intervention
  23. # that triples (delta = 3) the individual-specific odds of receiving treatment
  24. os_medshift <- medshift(W = example_data$W, A = example_data$A,
  25. Z = example_data$Z, Y = example_data$Y,
  26. delta = 3, estimator = "onestep",
  27. estimator_args = list(cv_folds = 3))
  28. summary(os_medshift)
  29. #> lwr_ci param_est upr_ci param_var eif_mean estimator
  30. #> 0.7401 0.788136 0.836172 0.000601 1.64686e-17 onestep

For details on how to use data adaptive regression (machine learning)
techniques in the estimation of nuisance parameters, consider consulting
the vignette that accompanies this package.


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 medshift R package, please cite the following:

  1. @article{diaz2020causal,
  2. title={Causal mediation analysis for stochastic interventions},
  3. author={D{\'\i}az, Iv{\'a}n and Hejazi, Nima S},
  4. year={2020},
  5. url = {https://doi.org/10.1111/rssb.12362},
  6. doi = {10.1111/rssb.12362},
  7. journal={Journal of the Royal Statistical Society: Series B
  8. (Statistical Methodology)},
  9. volume={},
  10. number={},
  11. pages={},
  12. publisher={Wiley Online Library}
  13. }
  14. @manual{hejazi2020medshift,
  15. author = {Hejazi, Nima S and D{\'\i}az, Iv{\'a}n},
  16. title = {{medshift}: Causal mediation analysis for stochastic
  17. interventions},
  18. year = {2020},
  19. url = {https://github.com/nhejazi/medshift},
  20. note = {R package version 0.1.4}
  21. }

License

© 2018-2022 Nima S. Hejazi

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

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

References





Chernozhukov, Victor, Denis Chetverikov, Mert Demirer, Esther Duflo,
Christian Hansen, Whitney Newey, and James Robins. 2018.
“Double/Debiased Machine Learning for Treatment and Structural
Parameters.” The Econometrics Journal 21 (1).
https://doi.org/10.1111/ectj.12097.



Coyle, Jeremy R, Nima S Hejazi, Ivana Malenica, Rachael V Phillips, and
Oleg Sofrygin. 2022. sl3: Modern Pipelines for Machine Learning and
Super Learning
. https://github.com/tlverse/sl3.
https://doi.org/10.5281/zenodo.1342293.



Dı́az, Iván, and Nima S Hejazi. 2020. “Causal Mediation Analysis for
Stochastic Interventions.” Journal of the Royal Statistical Society:
Series B (Statistical Methodology)
.
https://doi.org/10.1111/rssb.12362.



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



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



Zheng, Wenjing, and Mark J van der Laan. 2011. “Cross-Validated Targeted
Minimum-Loss-Based Estimation.” In Targeted Learning, 459–74.
Springer.