Learn R Programming

flexBCF (version 1.0.2)

get_tree_fits: Get fits of regression tree ensembles

Description

Computes posterior samples of evaluations of regression tree ensembles

Usage

get_tree_fits(fit,
              type = c("mu","tau"),
              X_cont = matrix(0, nrow = 1, ncol = 1),
              X_cat = matrix(0, nrow = 1, ncol = 1),
              verbose = TRUE, 
              print_every = NULL)

Value

A matrix whose rows correspond to MCMC iterations and who columns correspond to observations (i.e., rows of X_cont or X_cat).

Arguments

fit

Object returned by flexBCF.

type

Character which is equal to either "mu" or "tau". Determines which tree ensemble is used to make predictions before averaging. For evaluations of the prognostic function (resp. conditional average treatment effect function), set type == "mu" (resp. type == "tau").

X_cont

Matrix of continuous covariates for either the prognostic function \(\mu\) if (type == "mu") or CATE function \(\tau\) (type == "tau"). Note, predictors must be re-scaled to lie in the interval [-1,1]. Assumes that subjects are ordered so that all control subjects are listed before all treated subjects. Default is a 1x1 matrix, which signals that there are no continuous covariates

X_cat

Integer matrix of categorical covariates for either the prognostic function \(\mu\) if (type == "mu") or CATE function \(\tau\) (type == "tau"). Note categorical levels should be 0-indexed. That is, if a categorical predictor has 10 levels, the values should run from 0 to 9. Assumes that subjects are ordered so that all control subjects are listed before all treated subjects. Default is a 1x1 matrix, which signals that there are no categorical covariates

verbose

Logical, inciating whether to print progress to R console. Default is TRUE.

print_every

A status message is printed every print_every MCMC iterations. Whens print_every is NULL, get_tree_fits sets the value internally to be 1/10 the number of MCMC iterations.

Details

To reduce its memory footprint, flexBCF only returns posterior samples of the trees used to approximate \(\mu(X)\) and \(\tau(X)\). It does not return matrices containing posterior samples of these functions evaluated at each training observation. The function get_tree_fits() takes an object returned by flexBCF and evaluates the trees at the covariate values supplied by X_cont and X_cat.