Description Usage Arguments Value Examples
View source: R/predict_probit_bartBMA.R
This function produces predictions for a new dataset using a previously obtained bartBMA object.
1 | predict_probit_bartBMA(object, newdata)
|
object |
A probit_bartBMA object obtained using the probit_bartBMA function. |
newdata |
Covariate matrix for new dataset. |
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. |
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.