Probability Tilting Methods (IPT) for Causal Inference
by Bryan S. Graham, UC - Berkeley, e-mail: firstname.lastname@example.org
This package includes a Python 2.7 implementation of the Average Treatment Effect of the Treated (ATT) estimator introduced in Graham, Pinto and Egel (2016). The function att() allows for sampling weights as well as “clustered standard errors”, but these features have not yet been extensively tested.
An implementation of the Average Treatment Effect (ATE) estimator introduced in Graham, Pinto and Egel (2012) is planned for a future update.
This package is offered “as is”, without warranty, implicit or otherwise. While I would appreciate bug reports, suggestions for improvements and so on, I am unable to provide any meaningful user-support. Please e-mail me at email@example.com
Please cite both the code and the underlying source articles listed below when using this code in your research.
A simple example script to get started is:
>>>> # Append location of ipt module root directory to systems path >>>> # NOTE: Only required if ipt not "permanently" installed >>>> import sys >>>> sys.path.append('/Users/bgraham/Dropbox/Sites/software/ipt/') >>>> # Load ipt package >>>> import ipt as ipt >>>> # View help file >>>> help(ipt.att) >>>> # Read nsw data directly from Rajeev Dehejia's webpage into a >>>> # Pandas dataframe >>>> import numpy as np >>>> import pandas as pd >>>> nsw=pd.read_stata("http://www.nber.org/~rdehejia/data/nsw_dw.dta") >>>> # Make some adjustments to variable definitions in experimental dataframe >>>> nsw['constant'] = 1 # Add constant to observational dataframe >>>> nsw['age'] = nsw['age']/10 # Rescale age to be in decades >>>> nsw['re74'] = nsw['re74']/1000 # Recale earnings to be in thousands >>>> nsw['re75'] = nsw['re75']/1000 # Recale earnings to be in thousands >>>> # Treatment indicator >>>> D = nsw['treat'] >>>> # Balancing moments >>>> t_W = nsw[['constant','black','hispanic','education','age','re74','re75']] >>>> # Propensity score variables >>>> r_W = nsw[['constant']] >>>> # Outcome >>>> Y = nsw['re78'] >>>> # Compute AST estimate of ATT >>>> [gamma_as, vcov_gamma_ast, study_test, auxiliary_test, pi_eff_nsw, pi_s_nsw, pi_a_nsw, exitflag] = \ >>>> ipt.att(D, Y, r_W, t_W, study_tilt=True)