## Example from Schafer (2015). bart takes a few minutes to run (depending on computer).
example_data <- sim_data
# \donttest{
# This estimate takes a long time to run...
bart_list <- bart_est(Y = Y,
treat = T,
outcome_formula = Y ~ T + B.1 + B.2 + B.3 + B.4 + B.5 + B.6 + B.7 + B.8,
data = example_data,
grid_val = seq(8, 16, by = 1))
sample_index <- sample(1:1000, 100)
plot(example_data$T[sample_index],
example_data$Y[sample_index],
xlab = "T",
ylab = "Y",
main = "bart estimate")
lines(seq(8, 16, by = 1),
bart_list$param,
lty = 2,
lwd = 2,
col = "blue")
legend('bottomright',
"bart estimate",
lty=2,
lwd = 2,
col = "blue",
bty='Y',
cex=1)
# }
rm(example_data, bart_list, sample_index)
Run the code above in your browser using DataLab