因果推理的概率倾斜方法
ipt的Python项目详细描述
ipt:python 2.7包,用于通过反概率倾斜进行因果推理
作者:Bryan S.Graham,加州大学伯克利分校,电子邮件:bgraham@econ.berkeley.edu
这个包包括一个Python2.7实现,它实现了 Graham、Pinto和Egel(2016)引入的处理(ATT)估计量。函数att() 允许采样权重和“聚集标准错误”,但这些功能没有 但已经过了广泛的测试。
Graham介绍的平均治疗效果(ATE)估计器的实现, Pinto和Egel(2012)计划在未来更新。
本套餐按“原样”提供,不作任何担保、暗示或其他。尽管我会 感谢错误报告、改进建议等,我无法提供任何 有意义的用户支持。请在bgraham@econ.berkeley.edu给我发电子邮件
请在使用此代码时同时引用下面列出的代码和基础源文章 你研究中的代码。
一个简单的脚本示例如下:
>>>> # 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)
代码引用
- 格雷厄姆,布莱恩S.(2016)。“ipt:python 2.7包,用于通过反概率倾斜进行因果推理,”(版本0.2.2)
- [计算机程序]。可在https://github.com/bryangraham/ipt(2016年5月4日访问)
论文引文
-
格雷厄姆、布莱恩、克里斯汀·平托和丹尼尔·埃格尔。(2012年)。“力矩条件模型的逆概率倾斜
- 缺少数据,“经济研究回顾79(3):1053-1079” 格雷厄姆、布莱恩、克里斯汀·平托和丹尼尔·埃格尔。(2016年)。“通过 《学习倾斜辅助方法》(AST),《商业与经济统计杂志》31(2):288 - 301页。