Skip to content
No description, website, or topics provided.
R Shell
Branch: master
Clone or download
Latest commit dfbf71d May 31, 2019
Permalink
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
data
knownTestValues Formatting Documentation better. May 16, 2019
man
tests Formatting Documentation better. May 16, 2019
vignettes add BART package May 5, 2019
.Rbuildignore
.gitignore
DESCRIPTION VERSION 0.0.2.000 switching to BART May 12, 2019
LICENSE
NAMESPACE Deleting to output the fully specified functions. May 16, 2019
README.md Updating readme May 8, 2019
causalToolbox.Rproj Updating to the newest version of roxygen Oct 3, 2018

README.md

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")
devtools::install_github("soerenkuenzel/causalToolbox")

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.

Example

For details please read our paper: https://arxiv.org/pdf/1706.03461.pdf This example will not execute because there is no data.

library(causalToolbox)
packageVersion("causalToolbox")

# 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
# (https://arxiv.org/abs/1706.03461)

# 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.