In this repository we provide the code for the BCF-IV function and for the application part of the paper "Heterogeneous causal effects with imperfect compliance: a novel Bayesian machine learning approach" by F.J. Bargagli-Stoffi, K. De Witte and G. Gnecco. This function discovers the effect heterogeneity and provides two ways to estimate the heterogeneous causal effect (two-stage least squares and method-of-moments) in scenarios where the assignment mechanism is irregular. The BCF-IV function directly builds on the Bayesian Causal Forest algorithm by Hahn, Murray and Carvalho.
The function takes as inputs:
y
: the outcome variable;w
: the reception of the treatment variable (binary);z
: the assignment to the treatment variable (binary);max_depth
: the maximal depth of the tree generated by the function;n_burn
: the number of iterations discarded by the BCF-IV algorithm for the burn-in;n_sim
: the number of iterations used by the BCF-IV algorithm to get the posterior distribution of the estimands;binary
: this option should be set toTRUE
when the outcome variable is binary and toFALSE
if the outcome variable is either discrete or continuous.
The mm_bcf_iv function returns the discovered sub-population, the conditional complier average treatment effect (CCACE), the p-value for this effect, the p-value for a weak-instrument test, the proportion of compliers, the conditional intention-to-treat effect (CITT) and the proportion of compliers in the node.
More details on the R code for the BCF-IV function can be found here.
source("bcf-iv.R")
bcf_iv(y, w, z, x, max_depth = 2, n_burn= 2000, n_sim= 2000, binary = TRUE)
mm_bcf_iv(y, w, z, x, max_depth = 2, n_burn= 2000, n_sim= 2000, binary = TRUE)
- Falco J. Bargagli-Stoffi, Kristof De Witte, Giorgio Gnecco. Heterogeneous causal effects with imperfect compliance: a novel Bayesian machine learning approach. [link]
- P. Richard Hahn, Jared S. Murray, Carlos Carvalho. Bayesian regression tree models for causal inference: regularization, confounding, and heterogeneous effects. [link]