Skip to content
No description, website, or topics provided.
R Shell
Branch: master
Clone or download
Latest commit dfbf71d May 31, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
R Improvment May 31, 2019
R_beta Improving documentation May 4, 2019
Tune added a large dataset for test and a input checker for tbart Nov 30, 2018
knownTestValues Formatting Documentation better. May 16, 2019
tests Formatting Documentation better. May 16, 2019
vignettes add BART package May 5, 2019
DESCRIPTION VERSION switching to BART May 12, 2019
NAMESPACE Deleting to output the fully specified functions. May 16, 2019 Updating readme May 8, 2019
causalToolbox.Rproj Updating to the newest version of roxygen Oct 3, 2018

causalToolbox provides functions for estimating heterogenous treatment effects.

How to install

The latest development version can be installed directly from Github using devtools:

if (!require("devtools")) install.packages("devtools")

The package contains compiled code, and you must have a development environment to install the development version. (Use devtools::has_devel() to check whether you do.) If no development environment exists, Windows users download and install Rtools and macOS users download and install Xcode.


For details please read our paper: This example will not execute because there is no data.


# create example data set
simulated_experiment <- simulate_causal_experiment(
    ntrain = 1000,
    ntest = 1000,
    dim = 10)
feature_train <- simulated_experiment$feat_tr
w_train <- simulated_experiment$W_tr
yobs_train <- simulated_experiment$Yobs_tr

# create the hte object using honest Random Forests (RF)
xl_rf <- X_RF(feat = feature_train, tr = w_train, yobs = yobs_train)

# alternatively, use BART instead of honest Random Forests. If you are not going
# to be careful about hyperparemeter tuning, we suggest using BART.
xl_bart <- X_BART(feat = feature_train, tr = w_train, yobs = yobs_train)

# estimate the CATE
feature_test <- simulated_experiment$feat_te

cate_esti_rf <- EstimateCate(xl_rf, feature_test)
cate_esti_bart <- EstimateCate(xl_bart, feature_test)

# evaluate the performance
cate_true <- simulated_experiment$tau_te
mean((cate_esti_rf - cate_true) ^ 2)
mean((cate_esti_bart - cate_true) ^ 2)

# Create confidence intervals via bootstrapping. Note that honest Random
# Forests have theoretically valid CIs, BART does not. However, BART often
# performs well for prediction without extensive tuning. See our paper
# (

# do not run (takes a long time)
xl_ci_rf <- CateCI(xl_rf, feature_test, B = 500)
xl_ci_bart <- CateCI(xl_bart, feature_test, B = 500)
You can’t perform that action at this time.