predict_bartBMA: Predictions for a new dataset using an existing bartbma...

Description Usage Arguments Value Examples

View source: R/predict_bartBMA.R

Description

This function produces predictions for a new dataset using a previously obtained bartBMA object.

Usage

1
predict_bartBMA(object, newdata)

Arguments

object

A bartBMA object obtained using the barBMA function.

newdata

Covariate matrix for new dataset.

Value

A vector of predictions for the new dataset.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
set.seed(100)
#simulate some data
N <- 100
p<- 100
epsilon <- rnorm(N)
xcov <- matrix(runif(N*p), nrow=N)
y <- sin(pi*xcov[,1]*xcov[,2]) + 20*(xcov[,3]-0.5)^2+10*xcov[,4]+5*xcov[,5]+epsilon
epsilontest <- rnorm(N)
xcovtest <- matrix(runif(N*p), nrow=N)
ytest <- sin(pi*xcovtest[,1]*xcovtest[,2]) + 20*(xcovtest[,3]-0.5)^2+10*xcovtest[,4]+
  5*xcovtest[,5]+epsilontest

#Train the object 
bart_bma_example <- bartBMA(x.train = xcov,y.train=y,x.test=xcovtest,zero_split = 1, 
                            only_max_num_trees = 1,split_rule_node = 0)
#Obtain the prediction intervals
predict_bartBMA(bart_bma_example,newdata=xcovtest)

bartBMA documentation built on March 13, 2020, 5:06 p.m.