rf_sampler: Sample from a Random Forest Model

View source: R/estimators.R

rf_samplerR Documentation

Sample from a Random Forest Model

Description

This assumes a continuous response, so that the out-of-sample MSE can be used to estimate the outcome variability \sigma.

Usage

rf_sampler(fits, newdata = NULL, indices = NULL, ...)

Arguments

fits

The fitted RF model from which to draw samples.

newdata

A data.frame containing new inputs from which to sample responses. If NULL, defaults to the data used to estimate fit.

indices

The coordinates of the response from which to draw samples.

...

Additional parameters passed to rf_model's predict method.

Value

y_star A data.frame of samples y associated with the new inputs.

Examples

m <- rf_model()
fit <- estimator(m)(mpg ~ hp + wt, data = mtcars)
rf_sampler(fit, mtcars)

prf <- parallelize(ranger::ranger)
fit <- prf(mpg + disp ~ hp + wt, data = mtcars)
rf_sampler(fit, mtcars)

multimedia documentation built on Sept. 30, 2024, 9:28 a.m.