ShrinkageTrees

Bayesian shrinkage trees for high-dimensional (causal) inference in R

https://github.com/tijn-jacobs/shrinkagetrees

Science Score: 36.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
  • Academic publication links
    Links to: arxiv.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.5%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Bayesian shrinkage trees for high-dimensional (causal) inference in R

Basic Info
  • Host: GitHub
  • Owner: tijn-jacobs
  • License: other
  • Language: R
  • Default Branch: main
  • Homepage:
  • Size: 40.3 MB
Statistics
  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created 12 months ago · Last pushed 10 months ago
Metadata Files
Readme Changelog Contributing License

README.md

ShrinkageTrees R >= 4.2"> <img src= Lifecycle: maturing

This package provides functions for fitting Horseshoe Trees, Causal Horseshoe Forests, and their more general counterparts: Shrinkage Trees and Causal Shrinkage Forests.

These models allow for global-local shrinkage priors on tree step heights, enabling adaptive modeling in high-dimensional settings.

The functions can be used for:

1) High-dimensional prediction
2) High-dimensional causal inference 3) Estimaton of heterogeneous (conditional average) treatment effects

Supported outcome types: continuous, binary, and right-censored survival times.

The mathematical background and theoretical foundation for these models is described in the preprint Horseshoe Forests for High-Dimensional Causal Survival Analysis by T. Jacobs, W.N. van Wieringen, and S.L. van der Pas (arXiv:2507.22004).

✨ Features

  • Horseshoe, forest-wide horseshoe, empirical Bayes Horseshoe, and half-Cauchy priors
  • Flexible tree-based non-linear modeling of the ATE and CATE
  • Supports survival data with right-censoring (accelerated failure time model)
  • Efficient C++ backend via Rcpp

📦 Installation

The released version of ShrinkageTrees can be installed from CRAN:

r install.packages("ShrinkageTrees")

You can install the development version from GitHub:

```r

Install devtools if not already installed

install.packages("devtools") devtools::install_github("tijn-jacobs/ShrinkageTrees") ```

🚀 Example

```r library(ShrinkageTrees)

set.seed(42) n <- 100 p <- 1000

Generate covariates

X <- matrix(runif(n * p), ncol = p) Xtreat <- Xcontrol <- X treatment <- rbinom(n, 1, X[, 1]) tau <- 1 + X[, 2]/2 - X[, 3]/3 + X[, 4]/4

Generate survival times (on log-scale)

truetime <- X[, 1] + treatment * tau + rnorm(n) censortime <- log(rexp(n, rate = 0.05)) followup <- pmin(truetime, censortime) status <- as.integer(truetime <= censor_time)

Fit a standard Causal Horseshoe Forest (without propensity score adjustment)

fithorseshoe <- CausalHorseForest( y = followup, status = status, Xtraincontrol = Xcontrol, Xtraintreat = Xtreat, treatmentindicatortrain = treatment, outcometype = "right-censored", timescale = "log", numberoftrees = 200, k = 0.1, Npost = 5000, Nburn = 5000, storeposterior_sample = TRUE )

Posterior mean CATEs

CATEhorseshoe <- colMeans(fithorseshoe$trainpredictionssample_treat)

Posteriors of the ATE

postATEhorseshoe <- rowMeans(fithorseshoe$trainpredictionssampletreat)

Posterior mean ATE

ATEhorseshoe <- mean(postATE_horseshoe)

Plot the posterior of the ATE

``` Posterior ATE plot

📄 Documentation

  • In R: ?ShrinkageTrees, ?HorseTrees, ?CausalHorseForest, and ?CausalShrinkageForest for detailed help.
  • Examples and parameter descriptions can be found in each function’s documentation.

🤝 Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request. The software is designed to be flexible and modular, allowing for a wide variety of global-local shrinkage priors to be easily implemented and extended in future versions.

📜 License

This package is licensed under the MIT License.

🇪🇺 Acknowledgments

This project has received funding from the European Research Council (ERC) under the European Union’s Horizon Europe program under Grant agreement No. 101074082. Views and opinions expressed are however those of the author(s) only and do not necessarily reflect those of the European Union or the European Research Council Executive Agency. Neither the European Union nor the granting authority can be held responsible for them

Owner

  • Name: Tijn Jacobs
  • Login: tijn-jacobs
  • Kind: user

Applied Mathematicians

GitHub Events

Total
  • Public event: 1
  • Push event: 28
Last Year
  • Public event: 1
  • Push event: 28

Packages

  • Total packages: 1
  • Total downloads:
    • cran 512 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 1
  • Total maintainers: 1
cran.r-project.org: ShrinkageTrees

Regression Trees with Shrinkage Priors

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 512 Last month
Rankings
Dependent packages count: 25.8%
Dependent repos count: 31.7%
Average: 47.7%
Downloads: 85.6%
Maintainers (1)
Last synced: 10 months ago

Dependencies

DESCRIPTION cran
  • R >= 3.5.0 depends
  • Rcpp * imports
  • afthd * suggests
  • survival * suggests
  • testthat >= 3.0.0 suggests