txshift
txshift: Efficient estimation of the causal effects of stochastic interventions in R - Published in JOSS (2020)
Science Score: 95.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 14 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: joss.theoj.org, zenodo.org -
✓Committers with academic emails
2 of 3 committers (66.7%) from academic institutions -
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Keywords
causal-effects
causal-inference
censored-data
machine-learning
robust-statistics
statistics
stochastic-interventions
stochastic-treatment-regimes
targeted-learning
treatment-effects
variable-importance
Last synced: 6 months ago
·
JSON representation
Repository
:package: R/txshift: Efficient Estimation of the Causal Effects of Stochastic Interventions, with Corrections for Outcome-Dependent Sampling
Basic Info
- Host: GitHub
- Owner: nhejazi
- License: other
- Language: R
- Default Branch: master
- Homepage: https://codex.nimahejazi.org/txshift
- Size: 2.32 MB
Statistics
- Stars: 14
- Watchers: 5
- Forks: 5
- Open Issues: 3
- Releases: 3
Topics
causal-effects
causal-inference
censored-data
machine-learning
robust-statistics
statistics
stochastic-interventions
stochastic-treatment-regimes
targeted-learning
treatment-effects
variable-importance
Created over 8 years ago
· Last pushed over 1 year ago
Metadata Files
Readme
Changelog
Contributing
License
README.Rmd
---
output:
rmarkdown::github_document
bibliography: "inst/REFERENCES.bib"
---
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
# R/`txshift`
[](https://github.com/nhejazi/txshift/actions)
[](https://codecov.io/github/nhejazi/txshift?branch=master)
[](https://www.r-pkg.org/pkg/txshift)
[](https://CRAN.R-project.org/package=txshift)
[](https://CRAN.R-project.org/package=txshift)
[](https://www.repostatus.org/#active)
[](https://opensource.org/licenses/MIT)
[](https://doi.org/10.5281/zenodo.4070042)
[](https://doi.org/10.21105/joss.02447)
> Efficient Estimation of the Causal Effects of Stochastic Interventions
__Authors:__ [Nima Hejazi](https://nimahejazi.org) and [David
Benkeser](https://www.sph.emory.edu/faculty/profile/#!dbenkes)
---
## What's `txshift`?
The `txshift` R package is designed to provide facilities for the construction
of efficient estimators of the counterfactual mean of an outcome under
stochastic interventions that depend on the natural value of treatment
[@diaz2012population; @haneuse2013estimation]. `txshift `implements and builds
upon a simplified algorithm for the targeted maximum likelihood (TML) estimator
of such a causal parameter, originally proposed by @diaz2018stochastic, and
makes use of analogous machinery to compute an efficient one-step estimator
[@pfanzagl1985contributions]. `txshift` integrates with the [`sl3`
package](https://github.com/tlverse/sl3) [@coyle-sl3-rpkg] to allow for ensemble
machine learning to be leveraged in the estimation procedure.
For many practical applications (e.g., vaccine efficacy trials), observed data
is often subject to a two-phase sampling mechanism (i.e., through the use of a
two-stage design). In such cases, efficient estimators (of both varieties) must
be augmented to construct unbiased estimates of the population-level causal
parameter. @rose2011targeted2sd first introduced an augmentation procedure that
relies on introducing inverse probability of censoring (IPC) weights directly to
an appropriate loss function or to the efficient influence function estimating
equation. `txshift` extends this approach to compute IPC-weighted one-step and
TML estimators of the counterfactual mean outcome under a shift stochastic
treatment regime. The package is designed to implement the statistical
methodology described in @hejazi2020efficient and extensions thereof.
---
## Installation
For standard use, we recommend installing the package from
[CRAN](https://CRAN.R-project.org/package=txshift) via
```{r cran-installation, eval = FALSE}
install.packages("txshift")
```
_Note:_ If `txshift` is installed from
[CRAN](https://CRAN.R-project.org/package=txshift), the `sl3`, an enhancing
dependency that allows ensemble machine learning to be used for nuisance
parameter estimation, won't be included. We highly recommend additionally
installing `sl3` from GitHub via
[`remotes`](https://CRAN.R-project.org/package=remotes):
```{r sl3-gh-master-installation, eval = FALSE}
remotes::install_github("tlverse/sl3@master")
```
For the latest features, install the most recent _stable version_ of `txshift`
from GitHub via [`remotes`](https://CRAN.R-project.org/package=remotes):
```{r gh-master-installation, eval = FALSE}
remotes::install_github("nhejazi/txshift@master")
```
To contribute, install the _development version_ of `txshift` from GitHub via
[`remotes`](https://CRAN.R-project.org/package=remotes):
```{r gh-devel-installation, eval = FALSE}
remotes::install_github("nhejazi/txshift@devel")
```
---
## Example
To illustrate how `txshift` may be used to ascertain the effect of a treatment,
consider the following example:
```{r example, warning=FALSE}
library(txshift)
library(sl3)
set.seed(429153)
# simulate simple data
n_obs <- 500
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)))
# now, let's introduce a a two-stage sampling process
C_samp <- rbinom(n_obs, 1, plogis(W + Y))
# fit the full-data TMLE (ignoring two-phase sampling)
tmle <- txshift(
W = W, A = A, Y = Y, delta = 0.5,
estimator = "tmle",
g_exp_fit_args = list(
fit_type = "sl",
sl_learners_density = Lrnr_density_hse$new(Lrnr_hal9001$new())
),
Q_fit_args = list(fit_type = "glm", glm_formula = "Y ~ .")
)
tmle
# fit a full-data one-step estimator for comparison (again, no sampling)
os <- txshift(
W = W, A = A, Y = Y, delta = 0.5,
estimator = "onestep",
g_exp_fit_args = list(
fit_type = "sl",
sl_learners_density = Lrnr_density_hse$new(Lrnr_hal9001$new())
),
Q_fit_args = list(fit_type = "glm", glm_formula = "Y ~ .")
)
os
# fit an IPCW-TMLE to account for the two-phase sampling process
tmle_ipcw <- txshift(
W = W, A = A, Y = Y, delta = 0.5, C_samp = C_samp, V = c("W", "Y"),
estimator = "tmle", max_iter = 5, eif_reg_type = "glm",
samp_fit_args = list(fit_type = "glm"),
g_exp_fit_args = list(
fit_type = "sl",
sl_learners_density = Lrnr_density_hse$new(Lrnr_hal9001$new())
),
Q_fit_args = list(fit_type = "glm", glm_formula = "Y ~ .")
)
tmle_ipcw
# compare with an IPCW-agumented one-step estimator under two-phase sampling
os_ipcw <- txshift(
W = W, A = A, Y = Y, delta = 0.5, C_samp = C_samp, V = c("W", "Y"),
estimator = "onestep", eif_reg_type = "glm",
samp_fit_args = list(fit_type = "glm"),
g_exp_fit_args = list(
fit_type = "sl",
sl_learners_density = Lrnr_density_hse$new(Lrnr_hal9001$new())
),
Q_fit_args = list(fit_type = "glm", glm_formula = "Y ~ .")
)
os_ipcw
```
---
## Issues
If you encounter any bugs or have any specific feature requests, please [file an
issue](https://github.com/nhejazi/txshift/issues). Further details on filing
issues are provided in our [contribution
guidelines](https://github.com/nhejazi/txshift/blob/master/CONTRIBUTING.md).
---
## Contributions
Contributions are very welcome. Interested contributors should consult our
[contribution
guidelines](https://github.com/nhejazi/txshift/blob/master/CONTRIBUTING.md)
prior to submitting a pull request.
---
## Citation
After using the `txshift` R package, please cite the following:
@article{hejazi2020efficient,
author = {Hejazi, Nima S and {van der Laan}, Mark J and Janes, Holly
E and Gilbert, Peter B and Benkeser, David C},
title = {Efficient nonparametric inference on the effects of
stochastic interventions under two-phase sampling, with
applications to vaccine efficacy trials},
year = {2021},
doi = {10.1111/biom.13375},
url = {https://doi.org/10.1111/biom.13375},
journal = {Biometrics},
publisher = {Wiley Online Library}
}
@article{hejazi2020txshift-joss,
author = {Hejazi, Nima S and Benkeser, David C},
title = {{txshift}: Efficient estimation of the causal effects of
stochastic interventions in {R}},
year = {2020},
doi = {10.21105/joss.02447},
url = {https://doi.org/10.21105/joss.02447},
journal = {Journal of Open Source Software},
publisher = {The Open Journal}
}
@software{hejazi2022txshift-rpkg,
author = {Hejazi, Nima S and Benkeser, David C},
title = {{txshift}: Efficient Estimation of the Causal Effects of
Stochastic Interventions},
year = {2022},
doi = {10.5281/zenodo.4070042},
url = {https://CRAN.R-project.org/package=txshift},
note = {R package version 0.3.9}
}
---
## Related
* [R/`tmle3shift`](https://github.com/tlverse/tmle3shift) - An R package that
is an independent implementation of the same core methodology for TML
estimation as provided here but written based on the
[`tmle3`](https://github.com/tlverse/tmle3) engine of the [`tlverse`
ecosystem](https://github.com/tlverse). Unlike `txshift`, this package does
not provide tools for estimation under two-phase sampling designs.
* [R/`medshift`](https://github.com/nhejazi/medshift) - An experimental R
package for estimating causal mediation effects with stochastic interventions,
including via inverse probability weighted and asymptotically efficient
one-step estimators, as first described in @diaz2020causal.
* [R/`haldensify`](https://github.com/nhejazi/haldensify) - An R package for
estimating the generalized propensity score (conditional density) nuisance
parameter using the [highly adaptive
lasso](https://github.com/tlverse/hal9001) [@coyle-hal9001-rpkg;
@hejazi2020hal9001-joss] via an application of pooled hazard regression
[@diaz2011super].
* [R/`lmtp`](https://github.com/nt-williams/lmtp) - An R package for estimating
the causal effects of *longitudinal* modified treatment policies, which are a
generalization of the type of effect considered in this package. The LMTP
framework was first introduced in @diaz2021nonparametric and the `lmtp`
package is described in @williams2023lmtp.
---
## Funding
The development of this software was supported in part through grants from the
National Library of Medicine (award no. [T32
LM012417](https://reporter.nih.gov/project-details/9248418)), the National
Institute of Allergy and Infectious Diseases (award no. [R01
AI074345](https://reporter.nih.gov/project-details/9926564)), and the National
Science Foundation (award no. [DMS
2102840](https://www.nsf.gov/awardsearch/showAward?AWD_ID=2102840)).
---
## License
© 2017-2024 [Nima S. Hejazi](https://nimahejazi.org)
The contents of this repository are distributed under the MIT license. See below
for details:
```
MIT License
Copyright (c) 2017-2024 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
Owner
- Name: nima hejazi
- Login: nhejazi
- Kind: user
- Location: Boston, Massachusetts
- Company: Harvard Chan School of Public Health
- Website: https://nimahejazi.org
- Twitter: nshejazi
- Repositories: 19
- Profile: https://github.com/nhejazi
Assistant Professor of Biostatistics at the Harvard School of Public Health
JOSS Publication
txshift: Efficient estimation of the causal effects of stochastic interventions in R
Published
October 07, 2020
Volume 5, Issue 54, Page 2447
Authors
Tags
causal inference machine learning two-phase sampling efficient estimation targeted learning stochastic intervention modified treatment policyGitHub Events
Total
- Fork event: 1
Last Year
- Fork event: 1
Committers
Last synced: 7 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| Nima Hejazi | nh@n****g | 342 |
| David Benkeser | b****r@b****u | 6 |
| Benkeser | b****r@e****u | 3 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 26
- Total pull requests: 45
- Average time to close issues: 4 months
- Average time to close pull requests: 6 days
- Total issue authors: 6
- Total pull request authors: 3
- Average comments per issue: 1.46
- Average comments per pull request: 0.16
- Merged pull requests: 42
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- nhejazi (19)
- joethorley (3)
- benkeser (1)
- jeremyrcoyle (1)
- Lauren-EylerDang (1)
- alexpkeil1 (1)
Pull Request Authors
- nhejazi (36)
- benkeser (8)
- Lauren-EylerDang (1)
Top Labels
Issue Labels
enhancement (13)
bug (5)
question (4)
TODO (3)
Pull Request Labels
enhancement (20)
bug (8)
TODO (1)
Packages
- Total packages: 1
-
Total downloads:
- cran 274 last-month
- Total dependent packages: 0
- Total dependent repositories: 7
- Total versions: 5
- Total maintainers: 1
cran.r-project.org: txshift
Efficient Estimation of the Causal Effects of Stochastic Interventions
- Homepage: https://github.com/nhejazi/txshift
- Documentation: http://cran.r-project.org/web/packages/txshift/txshift.pdf
- License: MIT + file LICENSE
-
Latest release: 0.3.8
published about 4 years ago
Rankings
Dependent repos count: 11.1%
Forks count: 12.2%
Stargazers count: 15.1%
Average: 22.1%
Dependent packages count: 28.8%
Downloads: 43.4%
Maintainers (1)
Last synced:
6 months ago
Dependencies
DESCRIPTION
cran
- R >= 3.2.0 depends
- sl3 >= 1.4.3 enhances
- Rdpack * imports
- assertthat * imports
- data.table * imports
- ggplot2 * imports
- hal9001 >= 0.4.1 imports
- haldensify >= 0.2.1 imports
- latex2exp * imports
- lspline * imports
- mvtnorm * imports
- scales * imports
- stats * imports
- stringr * imports
- Rsolnp * suggests
- covr * suggests
- future * suggests
- future.apply * suggests
- knitr * suggests
- nnls * suggests
- origami >= 1.0.3 suggests
- ranger * suggests
- rmarkdown * suggests
- testthat * suggests
.github/workflows/R-CMD-check.yml
actions
- actions/checkout v4 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-tinytex v2 composite
