Compute posterior credible intervals for specified terms from a fitted BART model.
Source:R/posterior_transformation.R
compute_bart_posterior_interval.RdCompute posterior credible intervals for specified terms from a fitted BART model. Supports intervals for mean functions, variance functions, random effects, and overall outcome predictions.
Usage
compute_bart_posterior_interval(
model_object,
terms,
level = 0.95,
scale = "linear",
X = NULL,
leaf_basis = NULL,
rfx_group_ids = NULL,
rfx_basis = NULL
)Arguments
- model_object
A fitted BART or BCF model object of class
bartmodel.- terms
A character string specifying the model term(s) for which to compute intervals. Options for BART models are
"mean_forest","variance_forest","rfx", or"y_hat".- level
A numeric value between 0 and 1 specifying the credible interval level (default is 0.95 for a 95% credible interval).
- scale
(Optional) Scale of mean function predictions. Options are "linear", which returns predictions on the original scale of the mean forest / RFX terms, and "probability", which transforms predictions into a probability of observing
y == 1. "probability" is only valid for models fit with a probit outcome model. Default: "linear".- X
A matrix or data frame of covariates at which to compute the intervals. Required if the requested term depends on covariates (e.g., mean forest, variance forest, or overall predictions).
- leaf_basis
An optional matrix of basis function evaluations for mean forest models with regression defined in the leaves. Required for "leaf regression" models.
- rfx_group_ids
An optional vector of group IDs for random effects. Required if the requested term includes random effects.
- rfx_basis
An optional matrix of basis function evaluations for random effects. Required if the requested term includes random effects.