if (FALSE) {
#generate linear data
set.seed(11)
n = 500
p = 3
X = data.frame(matrix(runif(n * p), ncol = p))
y = 3*X[ ,1] + 2*X[ ,2] +X[ ,3] + rnorm(n)
##build BART regression model
bart_machine = bartMachine(X, y)
##generate plot
plot_y_vs_yhat(bart_machine)
#generate plot with prediction bands
plot_y_vs_yhat(bart_machine, prediction_intervals = TRUE)
}
Run the code above in your browser using DataLab