Skip to contents

A wrapper for dbarts::bart2() for use in nadir::super_learner().

Usage

lnr_bart(data, formula, weights = NULL, ...)

Arguments

data

A dataframe to train a learner / learners on.

formula

A regression formula to use inside this learner.

weights

Observation weights; see ?lm

...

Any extra arguments that should be passed to the internal model for model fitting purposes.

Value

A prediction function that accepts newdata, which returns predictions (a numeric vector of values, one for each row of newdata).

Details

BART is a Bayesian nonparametric sum-of-trees model with strong empirical performance in the causal inference and prediction literature; predictions returned are posterior mean predictions. Hyperparameters such as n.trees, n.samples, and n.burn may be passed through ....

Categorical predictor levels are retained from the training data so that prediction data are encoded using the same design matrix as the training data, even when some factor levels are absent from newdata.

See also

learners

Examples

# \donttest{
lnr_bart(mtcars, mpg ~ hp + disp + wt)(mtcars)
#>  [1] 21.25446 21.06996 23.93164 20.33089 17.50433 18.80935 14.63356 23.96805
#>  [9] 22.05070 18.81578 18.81578 16.18076 16.45138 16.36476 11.47852 11.52523
#> [17] 13.36373 30.04326 31.04536 31.52409 22.44798 16.06303 16.23890 14.14598
#> [25] 17.84854 30.00401 25.67542 28.95703 15.89661 19.96186 14.84895 21.83845
# }