MakeForest {SoftBart} | R Documentation |
Create an Rcpp_Forest Object
Description
Make an object of type Rcpp_Fores
t, which can be used to embed a soft
BART model into other models. Some examples are given in the package
vignette.
Usage
MakeForest(hypers, opts, warn = TRUE)
Arguments
hypers |
A list of hyperparameter values obtained from |
opts |
A list of MCMC chain settings obtained from |
warn |
If |
Value
Returns an object of type Rcpp_Forest
. If forest
is an
Rcpp_Forest
object then it has the following methods.
-
forest$do_gibbs(X, Y, X_test, i)
runsi
iterations of the Bayesian backfitting algorithm and predicts on the test setX_test
. The state of forest is also updated. -
forest$do_gibbs_weighted(X, Y, weights X_test, i)
runsi
iterations of the Bayesian backfitting algorithm and predicts on the test setX_test
; assumes thatY
is heteroskedastic with known weights. The state of forest is also updated. -
forest$do_predict(X)
returns the predictions from a matrixX
of predictors. -
forest$get_counts()
returns the number of times each variable has been used in a splitting rule at the current state offorest
. -
forest$get_s()
returns the splitting probabilities of the forest. -
forest$get_sigma()
returns the error standard deviation of the forest. -
forest$get_sigma_mu()
returns the standard deviation of the leaf node parameters. -
forest$get_tree_counts()
returns a matrix with a column for each predictor and a row for each tree that counts the number of times each predictor is used in each tree at the current state offorest
. -
forest$predict_iteration(X, i)
returns the predictions from a matrixX
of predictors at iterationi
. Requires thatopts$cache_trees = TRUE
inMakeForest(hypers, opts)
. -
forest$set_s(s)
sets the splitting probabilities of the forest tos
. -
forest$set_sigma(x)
sets the error standard deviation of the forest tox
. -
forest$num_gibbs
returns the number of iterations in total that the Gibbs sampler has been run.
Examples
X <- matrix(runif(100 * 10), nrow = 100, ncol = 10)
Y <- rowSums(X) + rnorm(100)
my_forest <- MakeForest(Hypers(X,Y), Opts())
mu_hat <- my_forest$do_gibbs(X,Y,X,200)