Skip to contents

Extract a forest from a BCF model by name. If the requested forest type is not found, an error is thrown. The following conventions are used for forest:

  • Prognostic (mu) forest: "prognostic", "prognostic_forest", "mu"

  • Treatment effect (tau) forest: "treatment", "treatment_forest", "tau"

  • Variance forest: "variance", "variance_forest"

The treatment forest is the raw treatment-effect forest tau(x) (without tau_0 or any adaptive-coding scaling); for the full CATE use extractParameter(object, "tau_hat_train").

Usage

# S3 method for class 'bcfmodel'
extractForest(object, term)

Arguments

object

Object of type bcfmodel containing draws of a BCF model and associated sampling outputs.

term

Name of the forest to extract (e.g., "prognostic", "treatment", "variance").

Value

Object of class ForestSamples containing a deep copy of the requested forest samples.

Examples

n <- 100
p <- 5
X <- matrix(runif(n*p), ncol = p)
pi_x <- 0.25 + 0.5*X[,1]
Z <- rbinom(n, 1, pi_x)
mu_x <- X[,1]*2
tau_x <- X[,2]*(-1)
y <- mu_x + tau_x*Z + rnorm(n)
bcf_model <- bcf(X_train=X, Z_train=Z, y_train=y, propensity_train=pi_x,
                 num_gfr=0, num_mcmc=10)
prognostic_forest <- extractForest(bcf_model, "prognostic")
treatment_forest <- extractForest(bcf_model, "treatment")