Learn R Programming

⚠️There's a newer version (2.1.1) of this package.Take me there.

FLAME (Fast, Large-scale, Almost Matching Exactly)

Overview of the FLAME algorithm

The FLAME algorithm provides fast and large-scale matching approach to causal inference. FLAME creates matches that include as many covariates as possible, and iteratively drops covariates that are successively less useful for predicting outcomes based on matching quality. Currently the FLAME package applies to categorical data, and provides two approaches for implementation - bit vectors and database management systems (e.g., PostgreSQL, SQLite). For data that has been preprocessed and fits in memory, bit vectors should be applied. For extremely large data that does not fit in memory, database systems should be applied.

For more details about the FLAME algorithm, please refer to the paper: FLAME: A Fast Large-scale Almost Matching Exactly Approach to Causal Inference and FLAME: An R Package for a Fast Large-scale Almost Matching Exactly Approach to Causal Inference

Installation

# Current version on GitHub
devtools::install_github("chiarui424/FLAME") 

Required data format

FLAME package requires input data to have specific format. First, input data should be a R Data Frame. Second, all covariates in the input data should be categorical covariates, represented by factor R data type. If there are continuous covariates, please consider regrouping. Third, input data columns should contain (1) covariates in factor data type, (2) outcome variable in numeric data type, and (3) variable specifying a unit is treated or control (treated = 1, control = 0) in factor data type. Lastly, though there are no requirements for input data column names, the column order should follow [covariates, outcome, treated]. Below is an example of input data with n units and m covariates.

x1x2...xm − 1xmoutcometreated
R data typefactorfactorfactorfactorfactornumericfactor
unit 101...123.81
unit 210...101.360
unit 301...01-7.250
........................
unit n01...10201

Holdout training set should also follow the same format.

Other requirements

  1. FLAME requires installation of python, specifically with at least python 2.7 version. If your computer system does not have python 2.7, install from here.

  2. For database systems implementation, FLAME package provides two versions - SQLite and PostgreSQL. PostgreSQL requires installation of external database system but it is faster. SQLite does not require external database system but is slower. If your computer does not have PostgreSQL installed, install from here. For connecting and setup of PostgreSQL server, please refer to the tutorialhttp://www.postgresqltutorial.com/connect-to-postgresql-database/)

  3. For database systems implementation, please name the database connection as db.

Some examples

Apply the FLAME Algorithm to Synthetic Data

Get Detailed Information After Matching

Match Quality

Copy Link

Version

Install

install.packages('FLAME')

Monthly Downloads

730

Version

1.0.0

License

GPL-3

Maintainer

Chia-Rui (Jerry) Chang

Last Published

December 17th, 2018

Functions in FLAME (1.0.0)

summary_plot

visualize matching process
toy_data

Toy Data
FLAME_PostgreSQL

PostgreSQL Database Implementation
Data_Generation

Generate Synthetic Data
ATE

Compute Average Treatment Effect
MATCH

Get Matched Units Given Certain Covariate Combination
AVG_EFFECT

Compute Estimated Treatment Effects
summary

Summary
FLAME_bit

Bit Vectors Implementation
FLAME_SQLite

SQLite Database Implementation
CATE

Get the Size and CATE of Matched Group(s)
CATE_plot

Summarize CATEs of All Matched Groups by Boxplot