bcf-iv

Package for heterogeneous causal effects in the presence of imperfect compliance (e.g., instrumental variables, fuzzy regression discontinuity designs)

https://github.com/fbargaglistoffi/bcf-iv

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 2 DOI reference(s) in README
  • Academic publication links
    Links to: arxiv.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.6%) to scientific vocabulary

Keywords

bayesian-statistics causal-inference fuzzy-rdd instrumental-variable interpretability interpretable-machine-learning machine-learning r statistics
Last synced: 6 months ago · JSON representation ·

Repository

Package for heterogeneous causal effects in the presence of imperfect compliance (e.g., instrumental variables, fuzzy regression discontinuity designs)

Basic Info
  • Host: GitHub
  • Owner: fbargaglistoffi
  • License: mit
  • Language: R
  • Default Branch: master
  • Homepage:
  • Size: 1.45 MB
Statistics
  • Stars: 16
  • Watchers: 2
  • Forks: 4
  • Open Issues: 1
  • Releases: 1
Topics
bayesian-statistics causal-inference fuzzy-rdd instrumental-variable interpretability interpretable-machine-learning machine-learning r statistics
Created over 6 years ago · Last pushed almost 2 years ago
Metadata Files
Readme License Citation

README.md

Bayesian Causal Forest with Instrumental Variable [BayesIV]

In this repository we provide the code for the BCF-IV and BCF-ITT functions 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 published in The Annals of Applied Statistics.

The article has also been covered and summarized in two blog posts on R-bloggers and YoungStatS . Check them out for a coincise summary of the main novelties introduced in the paper.

Getting Started

Installing the latest developing version:

r library(devtools) install_github("fbargaglistoffi/BCF-IV", ref="master")

Import:

r library("BayesIV")

Attention: BayesIV depends on bcf package, which, unfortunately, has just been removed from CRAN due to an un-addressed Issue. In order to run BayesIV package, manually install bcf package from GitHub following its installation guideline.

BCF-IV

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 function takes as inputs:

  • y: the outcome variable;
  • w: the reception of the treatment variable (binary);
  • z: the assignment to the treatment variable (binary);
  • x: the covariate matrix;
  • binary: TRUE if the outcome variable is binary, FALSEotherwise (default: FALSE);
  • n_burn: the number of iterations discarded by the BCF-IV algorithm for the burn-in (default: 500);
  • n_sim: the number of iterations used by the BCF-IV algorithm to get the posterior distribution of the estimands (default: 500);
  • inference_ratio: the ratio of observations to be assigned to the interence subsample (default: 0.5);
  • max_depth: the maximal depth of the tree generated by the function (default: 2);
  • 'cp: complexity parameter for the generated CART (default: 0.01);
  • minsplit: minimum observations needed to perform a binary split in the tree (default: 10);
  • adj_method: p-value adjustment method, options are "holm", bonferroni", "hockberg", "hommel", "BH", "BY", "fdr", "none" (default: "holm");
  • seed: random seed for reproducible results (default: 42).

The bcfiv_ 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

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);
  • x: the covariate matrix;
  • binary: TRUE if the outcome variable is binary, FALSEotherwise (default: FALSE);
  • max_depth: the maximal depth of the generated CART (default: 2);
  • n_burn: the number of iterations discarded by the BCF-IV algorithm for the burn-in (default: 500);
  • n_sim: the number of iterations used by the BCF-IV algorithm to get the posterior distribution of the estimands (default: 500);
  • inference_ratio: the ratio of observations to be assigned to the interence subsample (default: 0.5);
  • seed: random seed for reproducible results (default: 42).

The bcfitt_ 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.

Examples

```R

Generate the dataset

dataset <- generatedataset(n = 1000, p = 10, rho = 0, null = 0, effectsize = 2, compliance = 0.75) y <- dataset[["y"]] w <- dataset[["w"]] z <- dataset[["z"]] X <- dataset[["X"]]

BCF-IV

bcfiv(y, w, z, X, nburn = 2000, nsim = 2000, inferenceratio = 0.5, binary = FALSE, maxdepth = 2, adjmethod = "holm")

BCF-ITT

bcfitt(y, w, z, X, nburn= 2000, nsim = 2000, inferenceratio = 0.5, binary = FALSE, max_depth = 2) ```

For more exaustive synthetic examples check the folder examples/.

Reference

  • Bargagli-Stoffi, F.J., De Witte, K. and Gnecco, G., 2022. Heterogeneous causal effects with imperfect compliance: a Bayesian machine learning approach. The Annals of Applied Statistics, 16(3), pp.1986-2009. [paper] [preprint]

@article{bargagli2022heterogeneous, title={{Heterogeneous causal effects with imperfect compliance: a Bayesian machine learning approach}}, author={Bargagli-Stoffi, Falco J and De Witte, Kristof and Gnecco, Giorgio}, journal={The Annals of Applied Statistics}, volume={16}, number={3}, pages={1986--2009}, year={2022}, publisher={Institute of Mathematical Statistics} }

Owner

  • Name: Falco J. Bargagli-Stoffi
  • Login: fbargaglistoffi
  • Kind: user
  • Location: Cambridge, Massachusetts, USA
  • Company: Harvard University

Researcher @harvard

Citation (CITATION.cff)

cff-version: 1.1.0
message: "If you use this software, please cite it as below."
authors:
  - family-names: Bargagli-Stoffi
    given-names: Falco J.
    orcid: https://orcid.org/0000-0002-6131-8165
  - family-names: Cadei
    given-names: Riccardo
    orcid: https://orcid.org/0000-0003-2416-8943
title: "BayesIV: An R Package for Bayesian Causal Forest with Instrumental Variable"
version: 1.1.0
identifiers:
  - type: doi
    value: 10.5281/zenodo.10790054
date-released: 2023-03-06
url: "https://github.com/fbargaglistoffi/BCF-IV"

GitHub Events

Total
  • Watch event: 4
  • Fork event: 1
Last Year
  • Watch event: 4
  • Fork event: 1

Dependencies

DESCRIPTION cran
  • R >= 3.5.0 depends
  • AER * imports
  • MASS * imports
  • bartCause * imports
  • bcf * imports
  • lattice * imports
  • rattle * imports
  • rpart * imports