Discrete Bayesian Additive Regression Trees Sampler
A package for R, with C/C++.
Pre-built binaries of the package are built by CRAN. These can be installed from within R using the typical install.packages() mechanism.
Upgrading from 0.9-x
bart is now the formula-first front door (it was bart2, which remains as an alias for one release). The BayesTree-style interface is bartBT, with 0.9-x’s argument names and defaults; a bart call spelled the old way is forwarded to it with a warning for this release. Results differ from 0.9-x. The UPGRADING section of inst/NEWS.Rd lists every change that can break existing code.
Features
- Response families via
family =onbart():"gaussian","probit","logistic", accelerated-failure-time survival ("aft"), discrete-time survival hazard ("hazard","hazard.probit","hazard.logistic"), multinomial ("multinomial"), ordered categorical ("ordinal"), negative-binomial counts ("nbinom"), and semicontinuous two-part ("hurdle.lognormal"); family objects (?dbartsFamilies) carry family settings, such as the residual priorgaussian(sigma = chisq(3, 0.9)) - Outlier-robust Student-t residuals (
family = student(df)) - Heteroscedastic variance forest (
variance = ~ x1 + x2) - Monotonicity (
monotone), interaction (interactions), and block-additive (blocks) constraints - Missing predictor values modeled in place (MIA)
- Priors as objects (
?dbartsPriors): the tree prior (powerandbase, or DART variable selection withsplit.probs = dart(...)) and the leaf prior (leaf.prior = normal(...), or linear and Gaussian-process leaves withlinear(...)andgp(...)) - Categorical predictors split on level subsets (
factors = "categorical"); sparseMatrix::dgCMatrixand mixed dense/sparse predictor input - Warm starts from a previous fit (
warm.start) or XBART-style grow-from-root (n.grow.sweeps) - Reduced-precision residual storage for large problems (
storage = "single") - A sampler object (
dbarts()) whose response, predictors, offset, and weights can be changed between draws, for use as one step of a larger Gibbs sampler; multi-forest models such as BCF throughdbarts(forests = )
Steps to install from source:
- Install development tools for your operating system (dbarts needs R 4.2.0 or newer and a C++20 compiler):
- Install the
remotespackage from within R:
install.packages("remotes")- Run:
remotes::install_github("vdorie/dbarts")For package authors
Using dbarts from R needs no special linkage. Packages that call dbarts from compiled code use the flat C API in inst/include/dbarts/dbarts.h (LinkingTo: dbarts): the sampler is created in R and the C API works on its handle. The C++ headers of 0.9-x, R_C_interface.hpp among them, were removed in 1.0-0.