Entropy Balancing for Binary and Continuous Treatment
Python implementation of Entropy Balancing for binary and continuous treatment
Author: Eddie Yang
ebal for binary treatment is based on Hainmueller (2012) and ebal for continuous treatment is based on Tübbicke (2020) and Vegetabile et al. (2021).
Examples
# Binary
import pandas as pd
df = pd.read_csv('~/data.csv')
treatment="treat"
tmp_df = df[df[treatment].isin([0, 1])]
tmp_df = tmp_df.sort_values(by=[treatment])
tmp_df = tmp_df.reset_index(drop=True)
Y = tmp_df.Y.values
X = tmp_df.loc[:,0:10] #features
T = tmp_df[treatment].values #treatment
e = ebal_bin()
out = e.ebalance(T, X, Y)
# print ebal-weighted regression result
out['wls'].summary()
# check post-wegihting balance between treatment and control groups
e.check_balance(X, T, out['w'])
# Continuous
import pandas as pd
df = pd.read_csv('~/data_cont.csv')
Y = df.Y.values
X = df.iloc[:,4:] #features
T = df.T.values #treatment
e = ebal_con()
out = e.ebalance(T, X)
# check post-wegihting Pearson correlation
e.check_balance(X, T, out['w'])
Reference
- Hainmueller, J. (2012). Entropy balancing for causal effects: A multivariate reweighting method to produce balanced samples in observational studies. Political analysis, 20(1), 25-46.
- Vegetabile, B. G., Griffin, B. A., Coffman, D. L., Cefalu, M., Robbins, M. W., & McCaffrey, D. F. (2021). Nonparametric estimation of population average dose-response curves using entropy balancing weights for continuous exposures. Health Services and Outcomes Research Methodology, 21(1), 69-110.
- Tübbicke, S. (2020). Entropy balancing for continuous treatments. arXiv preprint arXiv:2001.06281.
- R Package 'ebal':https://github.com/cran/ebal