Skip to content

blind-contours/CVtreeMLE

Repository files navigation

CVtreeMLE

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

Codecov test coverage

Discovery of Critical Thresholds in Mixed Exposures and Estimation of Policy Intervention Effects using Targeted Learning

Author: David McCoy


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:

remotes::install_github("tlverse/sl3@devel")

Make sure sl3 installs correctly then install CVtreeMLE

remotes::install_github("blind-contours/CVtreeMLE@main")

Example

First load the package and other packages needed

library(CVtreeMLE)
library(sl3)
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

niehs_data <- NIEHS_data_1

head(niehs_data) %>%
  kableExtra::kbl(caption = "NIEHS Data") %>%
  kableExtra::kable_classic(full_width = FALSE, html_font = "Cambria")
NIEHS Data
obs Y X1 X2 X3 X4 X5 X6 X7 Z
1 7.534686 0.4157066 0.5308077 0.2223965 1.1592634 2.4577556 0.9438601 1.8714406 0
2 19.611934 0.5293572 0.9339570 1.1210595 1.3350074 0.3096883 0.5190970 0.2418065 0
3 12.664050 0.4849759 0.7210988 0.4629027 1.0334138 0.9492810 0.3664090 0.3502445 0
4 15.600288 0.8275456 1.0457137 0.9699040 0.9045099 0.9107914 0.4299847 1.0007901 0
5 18.606498 0.5190363 0.7802400 0.6142188 0.3729743 0.5038126 0.3575472 0.5906156 0
6 18.525890 0.4009491 0.8639886 0.5501847 0.9011016 1.2907615 0.7990418 1.5097039 0

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.

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

ptm <- proc.time()

niehs_results <- CVtreeMLE(
  data = as.data.frame(niehs_data),
  w = c("Z", "Z2", "Z3"),
  a = c(paste("X", seq(7), sep = "")),
  y = "Y",
  n_folds = 10,
  seed = seed,
  parallel_cv = TRUE,
  parallel = TRUE,
  family = "continuous",
  num_cores = 8,
  min_max = "min",
  min_obs = 25
)
proc.time() - ptm
#>    user  system elapsed 
#>  16.809   1.084 465.339

Mixture Results

First let’s look at the k-fold specific estimates:

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")
K-fold Results
are se lower_ci upper_ci p_val p_val_adj rmse mix_rule fold variables
-0.036 11.477 -22.530 22.458 0.997515 1 2.689 X2 \<= 0.42 1 X2
-0.173 7.816 -15.492 15.146 0.982327 1 2.759 X2 \<= 0.41 2 X2
0.486 15.208 -29.322 30.293 0.974526 1 2.906 X2 \<= 0.41 3 X2
0.969 15.328 -29.074 31.012 0.949580 1 3.469 X2 \<= 0.39 4 X2
0.543 13.659 -26.229 27.314 0.968304 1 3.358 X2 \<= 0.41 5 X2
0.537 15.434 -29.713 30.787 0.972228 1 3.110 X2 \<= 0.42 6 X2
0.129 15.465 -30.182 30.439 0.993363 1 3.191 X2 \<= 0.39 7 X2
-0.029 13.987 -27.443 27.386 0.998359 1 2.529 X2 \<= 0.39 8 X2
0.661 12.529 -23.895 25.217 0.957948 1 2.647 X2 \<= 0.39 9 X2
1.384 16.027 -30.029 32.797 0.931196 1 3.422 X2 \<= 0.39 10 X2

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:

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")
Oracle Mixture Results
Region ARE Standard Error Lower CI Upper CI P-value
0.248 4.351 -8.28 8.777 0.954462

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. Further details on filing issues are provided in our contribution guidelines.


Contributions

Contributions are very welcome. Interested contributors should consult our contribution guidelines 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 - 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