CVtreeMLE
CVtreeMLE: Efficient Estimation of Mixed Exposures using Data Adaptive Decision Trees and Cross-Validated Targeted Maximum Likelihood Estimation in R - Published in JOSS (2023)
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 10 DOI reference(s) in README and JOSS metadata -
✓Academic publication links
Links to: arxiv.org, joss.theoj.org, zenodo.org -
✓Committers with academic emails
1 of 4 committers (25.0%) from academic institutions -
○Institutional organization owner
-
✓JOSS paper metadata
Published in Journal of Open Source Software
Keywords
causal-effects
causal-inference
decision-trees
exposure-mixtures
machine-learning
robust-statistics
statistics
targeted-learning
variable-importance
Keywords from Contributors
interactions
mixed-exposure
Scientific Fields
Psychology
Social Sciences -
40% confidence
Last synced: 4 months ago
·
JSON representation
Repository
:deciduous_tree: :dart: Cross Validated Decision Trees with Targeted Maximum Likelihood Estimation
Basic Info
Statistics
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 7
- Releases: 1
Topics
causal-effects
causal-inference
decision-trees
exposure-mixtures
machine-learning
robust-statistics
statistics
targeted-learning
variable-importance
Created about 4 years ago
· Last pushed over 1 year ago
Metadata Files
Readme
Contributing
License
README.Rmd
---
output:
rmarkdown::github_document
bibliography: "inst/REFERENCES.bib"
always_allow_html: true
---
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-"
)
```
# `CVtreeMLE`
[](https://github.com/blind-contours/CVtreeMLE/actions)
[](https://codecov.io/github/blind-contours/CVtreeMLE?branch=master)
[](https://www.r-pkg.org/pkg/CVtreeMLE)
[](https://CRAN.R-project.org/package=CVtreeMLE)
[](https://CRAN.R-project.org/package=CVtreeMLE)
[](https://www.repostatus.org/#active)
[](https://opensource.org/licenses/MIT)
[](https://app.codecov.io/gh/blind-contours/CVtreeMLE?branch=main)
> Discovery of Critical Thresholds in Mixed Exposures and Estimation of Policy Intervention Effects using Targeted Learning
__Author:__ [David McCoy](https://davidmccoy.org)
---
## What is `CVtreeMLE`?
This package operationalizes the methodology presented here:
https://arxiv.org/abs/2302.07976
People often encounter multiple simultaneous exposures (e.g. several drugs or pollutants). Policymakers are interested in setting safe limits, interdictions, or recommended dosage combinations based on a combination of thresholds, one per exposure. Setting these thresholds is difficult because all relevant interactions between exposures must be accounted for. Previous statistical methods have used parametric estimators which do not directly address the question of safe exposure limits, rely on unrealistic assumptions, and do not result in a threshold based statistical quantity that is directly relevant to policy regulators.
Here we present an estimator that a) identifies thresholds that minimize/maximize the expected outcome controlling for covariates and other exposures; and which b) efficiently estimates a policy intervention which compares the expected outcome if everyone was forced to these safe levels compared to the observed outcome under observed exposure distribution.
This is done by using cross-validation where in training folds of the data, a custom g-computation tree-based search algorithm finds the minimizing region, and an estimation sample is used to estimate the policy intervention using targeted maximum likelihood estimation.
## Inputs and Outputs
This package takes in a mixed exposure, covariates, outcome, super learner stacks
of learners if determined (if not default are used), number of folds, minimum observations in a region, if the desired region is minimizer or maximizer and parallelization parameters.
The output are k-fold specific results for the region found in each fold with valid inference, a pooled estimate of the overall oracle parameter across all folds and pooled exposure sets if the region has some inconsistency across the folds.
---
## Installation
*Note:* Because `CVtreeMLE` package (currently) depends on `sl3` that
allows ensemble machine learning to be used for nuisance parameter
estimation and `sl3` is not on CRAN the `CVtreeMLE` package is not
available on CRAN and must be downloaded here.
There are many dependencies for `CVtreeMLE` so it's easier to break up
installation of the various packages to ensure proper installation.
`CVtreeMLE` uses the `sl3` package to build ensemble machine learners for each nuisance parameter.
Install `sl3` on devel:
```{r sl3_devel, eval = FALSE}
remotes::install_github("tlverse/sl3@devel")
```
Make sure `sl3` installs correctly then install `CVtreeMLE`
```{r CVtreeMLE_install, eval = FALSE}
remotes::install_github("blind-contours/CVtreeMLE@main")
```
---
## Example
First load the package and other packages needed
```{r libraries, warning=FALSE, message=FALSE}
library(CVtreeMLE)
library(sl3)
library(dplyr)
library(kableExtra)
library(ggplot2)
seed <- 98484
set.seed(seed)
```
To illustrate how `CVtreeMLE` may be used to find and estimate a region that, if intervened on would lead to the biggest reduction in an outcome we use synthetic data from the National Institute of Environmental Health:
## National Institute of Environmental Health Data
The 2015 NIEHS Mixtures Workshop was
developed to determine if new mixture methods detect ground-truth interactions
built into the simulated data. In this way we can simultaneously show
`CVtreeMLE` output, interpretation and validity.
For detailed information on this simulated data please see:
https://github.com/niehs-prime/2015-NIEHS-MIxtures-Workshop
```{r load_NIEHS_data, warning=FALSE}
niehs_data <- NIEHS_data_1
head(niehs_data) %>%
kableExtra::kbl(caption = "NIEHS Data") %>%
kableExtra::kable_classic(full_width = FALSE, html_font = "Cambria")
```
Briefly, this synthetic data can be considered the results of a prospective
cohort epidemiologic study. The outcome cannot cause the exposures (as might
occur in a cross-sectional study). Correlations between exposure variables can
be thought of as caused by common sources or modes of exposure. The nuisance
variable Z can be assumed to be a potential confounder and not a collider.
There are 7 exposures which have a complicated dependency structure. $X_3$ and
$X_6$ do not have an impact on the outcome.
One issue is that many machine learning algorithms will fail given only 1
variable passed as a feature so let's add some other covariates.
```{r add_covariates, warning=FALSE}
niehs_data$Z2 <- rbinom(nrow(niehs_data),
size = 1,
prob = 0.3
)
niehs_data$Z3 <- rbinom(nrow(niehs_data),
size = 1,
prob = 0.1
)
```
## Run `CVtreeMLE`
```{r run_simulation, warnings = FALSE, message=FALSE}
ptm <- proc.time()
# Convert continuous X variables to their corresponding deciles for example
niehs_data <- niehs_data %>%
mutate(across(starts_with("X"), ~ ntile(., 10), .names = "decile_{col}"))
niehs_results <- CVtreeMLE(
data = as.data.frame(niehs_data),
w = c("Z", "Z2", "Z3"),
a = c("decile_X1", "decile_X2", "decile_X3", "decile_X4", "decile_X5", "decile_X6", "decile_X7"),
y = "Y",
n_folds = 7,
seed = seed,
parallel_cv = TRUE,
parallel = TRUE,
family = "continuous",
num_cores = 8,
min_max = "min",
max_depth = 2,
min_obs = 25
)
proc.time() - ptm
```
## Mixture Results
First let's look at the k-fold specific estimates:
```{r k_fold_results}
k_fold_results <- niehs_results$`V-Specific Mix Results`
k_fold_results %>%
kableExtra::kbl(caption = "K-fold Results") %>%
kableExtra::kable_classic(full_width = FALSE, html_font = "Cambria")
```
This indicates that the exposure X2 was found in every fold to have the most minimizing impact on endocrine disruption if all individuals were were forced to be exposed to levels less around 0.41. This resembles a policy where, if everyone were still exposed to the other exposures but we created a regulation that restricted individuals to only exposure of X2 less than 0.41.
The pooled estimates, leveraging all the folds for our estimates oracle target parameter looks like:
```{r oracle_results}
pooled_mixture_results <- niehs_results$`Oracle Region Results`
pooled_mixture_results %>%
kableExtra::kbl(caption = "Oracle Mixture Results") %>%
kableExtra::kable_classic(full_width = FALSE, html_font = "Cambria")
```
Additional details for this and other features are given in the vignette.
---
## Issues
If you encounter any bugs or have any specific feature requests,
please [file an
issue](https://github.com/blind-contours/CVtreeMLE/issues). Further details
on filing
issues are provided in our [contribution
guidelines](https://github.com/blind-contours/
CVtreeMLE/blob/main/CONTRIBUTING.md).
---
## Contributions
Contributions are very welcome. Interested contributors should consult our
[contribution
guidelines](https://github.com/blind-contours/CVtreeMLE/blob/main/contributing.md)
prior to submitting a pull request.
---
## Citation
After using the `CVtreeMLE` R package, please cite the following:
@article{McCoy2023,
doi = {10.21105/joss.04181},
url = {https://doi.org/10.21105/joss.04181},
year = {2023}, publisher = {The Open Journal},
volume = {8}, number = {82}, pages = {4181},
author = {David McCoy and Alan Hubbard and Mark Van der Laan},
title = {CVtreeMLE: Efficient Estimation of Mixed Exposures using Data Adaptive Decision Trees and Cross-Validated Targeted Maximum Likelihood Estimation in R},
journal = {Journal of Open Source Software} }
---
## Related
* [R/`sl3`](https://github.com/tlverse/sl3) - An R package
providing implementation for Super Learner ensemble machine learning
algorithms.
---
## Funding
The development of this software was supported in part through grants from the
NIH-funded Biomedical Big Data Training Program at UC Berkeley where I was a
biomedical big data fellow.
---
## License
© 2017-2024 David B. McCoy
The contents of this repository are distributed under the MIT license. See
below for details:
```
MIT License
Copyright (c) 2017-2024 David B. McCoy
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: David McCoy
- Login: blind-contours
- Kind: user
- Repositories: 3
- Profile: https://github.com/blind-contours
JOSS Publication
CVtreeMLE: Efficient Estimation of Mixed Exposures using Data Adaptive Decision Trees and Cross-Validated Targeted Maximum Likelihood Estimation in R
Published
February 21, 2023
Volume 8, Issue 82, Page 4181
Authors
David McCoy
Division of Environmental Health Sciences, University of California, Berkeley, CA, United States of America
Division of Environmental Health Sciences, University of California, Berkeley, CA, United States of America
Tags
causal inference machine learning decision trees efficient estimation targeted learning iterative backfitting mixed exposuresGitHub Events
Total
- Fork event: 1
Last Year
- Fork event: 1
Committers
Last synced: 5 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| blind-contours | d****y@b****u | 256 |
| David Brenton McCoy | d****y@l****c | 10 |
| David Brenton McCoy | d****y@l****c | 5 |
| David Brenton McCoy | d****y@l****c | 4 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 31
- Total pull requests: 2
- Average time to close issues: 5 months
- Average time to close pull requests: less than a minute
- Total issue authors: 5
- Total pull request authors: 1
- Average comments per issue: 1.97
- Average comments per pull request: 1.0
- Merged pull requests: 2
- 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
- GaryBAYLOR (13)
- wleoncio (5)
- lightning-auriga (5)
- osorensen (5)
- blind-contours (3)
Pull Request Authors
- blind-contours (2)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
DESCRIPTION
cran
- R >= 2.10 depends
- Hmisc * imports
- MASS * imports
- assertthat * imports
- cvTools * imports
- data.table * imports
- dplyr * imports
- foreach * imports
- furrr * imports
- future * imports
- ggplot2 * imports
- magrittr * imports
- partykit * imports
- pre * imports
- purrr * imports
- rlang * imports
- sl3 * imports
- stats * imports
- stringr * imports
- covr * suggests
- kableExtra * suggests
- knitr * suggests
- mlbench * suggests
- rmarkdown * suggests
- testthat >= 3.0.0 suggests
- xml2 * suggests
.github/workflows/R-CMD-check.yml
actions
- actions/checkout v2 composite
- r-lib/actions/setup-pandoc v1 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-tinytex v1 composite
.github/workflows/draft-pdf.yml
actions
- actions/checkout v2 composite
- actions/upload-artifact v1 composite
- openjournals/openjournals-draft-action master composite
.github/workflows/lint.yaml
actions
- actions/checkout v2 composite
- r-lib/actions/setup-r v1 composite
- r-lib/actions/setup-r-dependencies v1 composite