mc.pwbart: Predicting new observations based on a previously fitted BART...

View source: R/mc.pwbart.R

mc.pwbartR Documentation

Predicting new observations based on a previously fitted BART model with parallel computation

Description

BART is a Bayesian approach to nonparametric function estimation and inference using a sum of trees.
For a continuous response y and a p-dimensional vector of predictors x = (x_1, ..., x_p)', BART models y and x using

y = f(x) + ε,

where f is a sum of Bayesian regression trees function and ε ~ N(0, σ^2).
For a binary response y, probit BART models y and x using

P(Y=1|x)=Φ[f(x)],

where Φ is the CDF of the standard normal distribution and f is a sum of Bayesian regression trees function.
The function mc.pwbart() is inherited from the CRAN R package 'BART'.

Usage

mc.pwbart(
  x.test,
  treedraws,
  rm.const,
  mu = 0,
  mc.cores = 2L,
  transposed = FALSE,
  dodraws = TRUE,
  nice = 19L
)

Arguments

x.test

A matrix or a data frame of predictors values for prediction with each row corresponding to an observation and each column corresponding to a predictor.

treedraws

A list which is the $treedraws returned from the function wbart() or pbart().

rm.const

A vector which is the $rm.const returned from the function wbart() or pbart().

mu

Mean to add on to y prediction.

mc.cores

The number of threads to utilize.

transposed

A Boolean argument indicating whether the matrix x.test is transposed. When running pwbart() or mc.pwbart() in parallel, it is more memory-efficient to transpose x.test prior to calling the internal versions of these functions.

dodraws

A Boolean argument indicating whether to return the draws themselves (the default), or whether to return the mean of the draws as specified by dodraws=FALSE.

nice

Set the job niceness. The default niceness is 19 and niceness goes from 0 (highest) to 19 (lowest).

Value

Returns the predictions for x.test. If dodraws=TRUE, return a matrix of prediction with each row corresponding to a draw and each column corresponding to a new observation; if dodraws=FALSE, return a vector of predictions which are the mean of the draws.

Author(s)

Chuji Luo: cjluo@ufl.edu and Michael J. Daniels: daniels@ufl.edu.

References

Chipman, H. A., George, E. I. and McCulloch, R. E. (2010). "BART: Bayesian additive regression trees." Ann. Appl. Stat. 4 266–298.

Linero, A. R. (2018). "Bayesian regression trees for high-dimensional prediction and variable selection." J. Amer. Statist. Assoc. 113 626–636.

Luo, C. and Daniels, M. J. (2021) "Variable Selection Using Bayesian Additive Regression Trees." arXiv preprint arXiv:2112.13998.

Rockova V, Saha E (2019). “On theory for BART.” In The 22nd International Conference on Artificial Intelligence and Statistics (pp. 2839–2848). PMLR.

Sparapani, R., Spanbauer, C. and McCulloch, R. (2021). "Nonparametric machine learning and efficient computation with bayesian additive regression trees: the BART R package." J. Stat. Softw. 97 1–66.

See Also

wbart, pbart and mc.pwbart.

Examples

 
## simulate data (Scenario C.M.1. in Luo and Daniels (2021))
set.seed(123)
data = mixone(100, 10, 1, FALSE)
## run wbart() function
res = wbart(data$X, data$Y, ntree=10, nskip=100, ndpost=100)
## parallel::mcparallel/mccollect do not exist on windows
if(.Platform$OS.type=='unix') {
## test pwbart() function
  x.test = mixone(5, 10, 1, FALSE)$X
  pred = mc.pwbart(x.test, res$treedraws, res$rm.const, mu=mean(data$Y), mc.cores=2)
}

BartMixVs documentation built on May 5, 2022, 9:05 a.m.