Git Product home page Git Product logo

bcf-iv's Introduction

Code for Bayesian Causal Forest with Instrumental Variable

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.

BCF-IV function

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 to TRUE when the outcome variable is binary and to FALSE 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.

BCF-ITT function

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 to TRUE when the outcome variable is binary and to FALSE 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.

Example usage

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)

References

  • 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]

bcf-iv's People

Contributors

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