Giter Site home page Giter Site logo

causaltoolbox's Introduction

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)

causaltoolbox's People

Contributors

soerenkuenzel avatar actang avatar zuhdydufjdj avatar dannver avatar julianneoshiro avatar sjsw avatar

Watchers

paper2code - bot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.