computeForestLeafVariances {stochtree} | R Documentation |
Compute vector of forest leaf scale parameters
Description
Return each forest's leaf node scale parameters.
If leaf scale is not sampled for the forest in question, throws an error that the leaf model does not have a stochastic scale parameter.
Usage
computeForestLeafVariances(model_object, forest_type, forest_inds = NULL)
Arguments
model_object |
Object of type |
forest_type |
Which forest to use from 1. BART
2. BCF
|
forest_inds |
(Optional) Indices of the forest sample(s) for which to compute leaf indices. If not provided,
this function will return leaf indices for every sample of a forest.
This function uses 0-indexing, so the first forest sample corresponds to |
Value
Vector of size length(forest_inds)
with the leaf scale parameter for each requested forest.
Examples
X <- matrix(runif(10*100), ncol = 10)
y <- -5 + 10*(X[,1] > 0.5) + rnorm(100)
bart_model <- bart(X, y, num_gfr=0, num_mcmc=10)
computeForestLeafVariances(bart_model, "mean")
computeForestLeafVariances(bart_model, "mean", 0)
computeForestLeafVariances(bart_model, "mean", c(1,3,5))