Sample from the posterior predictive distribution for outcomes modeled by BART
Source:R/posterior_transformation.R
sample_bart_posterior_predictive.RdSample from the posterior predictive distribution for outcomes modeled by BART
Usage
sample_bart_posterior_predictive(
model_object,
X = NULL,
leaf_basis = NULL,
rfx_group_ids = NULL,
rfx_basis = NULL,
num_draws_per_sample = NULL
)Arguments
- model_object
A fitted BART model object of class
bartmodel.- X
A matrix or data frame of covariates. Required if the BART model depends on covariates (e.g., contains a mean or variance forest).
- leaf_basis
A matrix of bases for mean forest models with regression defined in the leaves. Required for "leaf regression" models.
- rfx_group_ids
A vector of group IDs for random effects model. Required if the BART model includes random effects.
- rfx_basis
A matrix of bases for random effects model. Required if the BART model includes random effects.
- num_draws_per_sample
The number of posterior predictive samples to draw for each posterior sample. Defaults to a heuristic based on the number of samples in a BART model (i.e. if the BART model has >1000 draws, we use 1 draw from the likelihood per sample, otherwise we upsample to ensure intervals are based on at least 1000 posterior predictive draws).