In this repository we provide the code for the BCF-IV and BCF-ITT functions and for the application and simulations' Sections of the paper "Heterogeneous causal effects with imperfect compliance: a Bayesian machine learning approach" by F.J. Bargagli-Stoffi, K. De Witte and G. Gnecco.
The BCF-IV function discovers and estimates, in an interpretable manner, the effects heterogeneity in settings where the assignment mechanism is irregular (e.g., instrumental variable and fuzzy regression discontinuity scenarios). This function is directly built to discover and estimate the heterogeneity in the Complier Average Treatment Effects (CACE). The BCF-ITT function discovers the heterogeneity in the intention-to-treat (ITT) and then estimates the effect both for the conditional ITT and the conditional CACE for the discovered subgroups.
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);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;inference_ratio
: the ratio of observations to be assigned to the interence subsample;binary
: this option should be set toTRUE
when the outcome variable is binary and toFALSE
if the outcome variable is either discrete or continuous;max_depth
: the maximal depth of the tree generated by the function;cp
: complexity parameter for the generated CART (default is 0.01);minsplit
: minimum observations needed to perform a binary split in the tree (default is 10);adj_method
: p-value adjustment method (default is "holm"), other options are "bonferroni", "hockberg", "hommel", "BH", "BY", "fdr", "none";seed
random seed for reproducible results (default is 42).
The 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 adjusted p-value, the proportion of compliers, the conditional intention-to-treat effect (CITT) and the proportion of compliers in the node.
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);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;inference_ratio
: the ratio of observations to be assigned to the interence subsample;binary
: this option should be set toTRUE
when the outcome variable is binary and toFALSE
if the outcome variable is either discrete or continuous;max_depth
: the maximal depth of the tree generated by the function.
The bcf_itt function returns the discovered sub-population, the conditional complier average treatment effect (CCACE), the conditional intention-to-treat (CITT), the p-value for this effect, the p-value for a weak-instrument test, the adjusted p-value, the proportion of compliers, the conditional intention-to-treat effect (CITT) and the proportion of compliers in the node.
source("bcf-iv.R")
bcf_iv(y, w, z, x, n_burn = 2000, n_sim = 2000, inference_ratio = 0.50, binary = TRUE, max_depth = 2, adj_method = "holm")
bcf_itt(y, z, x, n_burn= 2000, n_sim = 2000, inference_ratio = 0.50, binary = TRUE, max_depth = 2)
- 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]