predict_probit_bartBMA: Predictions for a new dataset using an existing...

Description Usage Arguments Value Examples

View source: R/predict_probit_bartBMA.R

Description

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

Usage

1
predict_probit_bartBMA(object, newdata)

Arguments

object

A probit_bartBMA object obtained using the probit_bartBMA function.

newdata

Covariate matrix for new dataset.

Value

The output is a list of length 2:

probs

A vector of estimated probabilities for newdata.

pred_binary

A vector of binary predictions for newdata.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#Example from BART package (McCulloch et al. 2019)
set.seed(99)
n=100
x = sort(-2+4*runif(n))
X=matrix(x,ncol=1)
f = function(x) {return((1/2)*x^3)}
FL = function(x) {return(exp(x)/(1+exp(x)))}
pv = FL(f(x))
y = rbinom(n,1,pv)

trained_probit_bbma <- probit_bartBMA(x.train = X,y.train = y)

np=100
xp=-2+4*(1:np)/np
Xp=matrix(xp,ncol=1)

predict_probit_bartBMA(trained_probit_bbma,Xp)

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