rf_model: Random Forest Model

View source: R/estimators.R

rf_modelR Documentation

Random Forest Model

Description

Apply a random forest model in parallel across a vector of responses $y$ in either an outcome or mediation model. This is a natural choice when the relationship between inputs and outputs is thought to be nonlinear. Internally, each of the models across the response are estimated using the 'ranger' package.

Usage

rf_model(progress = TRUE, ...)

Arguments

progress

A logical indicating whether to show a progress bar during estimation.

...

Keyword parameters passed to ranger() in the 'ranger' package.

Value

model An object of class model with estimator, predictor, and sampler functions associated wtih a lienar model.

See Also

model lm_model rf_model glmnet_model brms_model

Examples

exper <- demo_joy() |>
    mediation_data("PHQ", "treatment", starts_with("ASV"))
multimedia(exper, rf_model(num.trees = 10)) |>
    estimate(exper)

# example with another dataset
exper <- demo_spline(tau = c(2, 1)) |>
    mediation_data(starts_with("outcome"), "treatment", "mediator")
multimedia(exper, rf_model(num.trees = 20, max.depth = 2)) |>
    estimate(exper)

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