其他
因果推理的匹配方法及其在Stata中的实现
计量经济学服务中心专辑汇总!计量百科·资源·干货:
Stata |Python |Matlab |Eviews |R Geoda |ArcGis |GeodaSpace |SPSS 一文读懂 |数据资源 |回归方法 |网络爬虫 门限回归 |工具变量 |内生性 |空间计量 因果推断 |合成控制法 |倾向匹配得分 |断点回归 |双重差分 面板数据 | 动态面板数据
匹配,尤其是在倾向评分方面,已经成为一种非常流行的评价方法。事实上,匹配是选择匹配(或重新加权)的比较组的最佳方法,该比较组看起来像感兴趣的治疗组。
在本文中,将在一般的因果推理问题中介绍匹配方法,强调它们的优缺点,并简要概述不同的匹配估计量。然后,使用psmatch2演示Stata中基于真实数据的实际示例。然后,我将展示如何实现其中一些估计,并强调一些实现问题
本文主要包括两部分,第一部分为课件,第二部分为相应的文档代码
因果推理的匹配方法及其在Stata中的实现
来源:Barbara Sianesi,IFS,Stata Users’ Group Meeting
对应文档代码
// PSMATCH2 EXAMPLE
use nsw_psid, clear
desc
more
ta treated
more
// Propensity score
/************************************************************************/
more
dprobit treated age black hispanic married educ nodegree re75
more
cap drop score
predict double score
more
// Common support
/************************************************************************/
more
summarize score if treated==1, detail
more
summarize score if treated==0, detail
more
density2 score, group(treated)
more
psgraph, treated(treated) pscore(score) bin(50)
more
// Nearest neighbour without replacement without caliper
/************************************************************************/
more
psmatch2 treated, pscore(score) outcome(re78) noreplacement
more
pstest2 age black hispanic married educ nodegree re75, sum graph
more
// Nearest neighbour without replacement within caliper
/************************************************************************/
more
psmatch2 treated, pscore(score) outcome(re78) noreplacement caliper(0.01)
more
summarize _support if treated==1
display 1-r(mean)
more
psgraph
more
pstest2 age black hispanic married educ nodegree re75, sum graph
more
// Nearest neighbour with replacement
/************************************************************************/
more
psmatch2 treated, pscore(score) outcome(re78)
more
summarize _pdif, detail
more
psmatch2 treated, pscore(score) outcome(re78) caliper(0.01)
more
summarize _support if treated==1
display 1-r(mean)
more
tab _weight if treated==0
more
psgraph
more
density2 score, g(treated)
more
density2 score, g(treated) m(_weight)
more
pstest2 age black hispanic married educ nodegree re75, sum graph
more
density2 re75 if re75<40000, g(treated)
more
density2 re75 if re75<40000, g(treated) m(_weight)
more
// >1-to-1 matching
/************************************************************************/
more
psmatch2 treated, pscore(score) outcome(re78) neigh(10)
more
psmatch2 treated, pscore(score) outcome(re78) neigh(20)
more
psmatch2 treated, pscore(score) outcome(re78) neigh(10) cal(0.01)
more
tab _nn if treated==1
more
psmatch2 treated, pscore(score) outcome(re78) neigh(20) cal(0.01)
more
tab _nn if treated==1
more
// Kernel matching
/************************************************************************/
more
psmatch2 treated, pscore(score) outcome(re78) kernel k(epan) bw(0.06)
more
psmatch2 treated, pscore(score) outcome(re78) kernel k(normal) bw(0.06)
more
psmatch2 treated, pscore(score) outcome(re78) kernel k(epan) bw(0.01)
more
psmatch2 treated, pscore(score) outcome(re78) kernel k(normal) bw(0.01)
more
// Mahalanobis-metric matching
/************************************************************************/
more
psmatch2 treated, mahal(age black hispanic married educ nodegree re75) outcome(re78)
more
pstest2 age black hispanic married educ nodegree re75, sum graph
more
psmatch2 treated, mahal(score age black hispanic married educ nodegree re75) outcome(re78)
more
pstest2 age black hispanic married educ nodegree re75, sum graph
more
// ATNT
/************************************************************************/
more
gen treat0 = 1-treated
more
psmatch2 treat0 age black hispanic married educ nodegree re75, outcome(re78)
* Remember to take -1*(effect) for ATNT.
more
sum _pdif, d
more
psmatch2 treat0 age black hispanic married educ nodegree re75, outcome(re78) cal(0.01)
more
tab _weight if treat0==0
more
pstest2 age black hispanic married educ nodegree re75, sum graph
more
psmatch2 treated age black hispanic married educ nodegree re75, outcome(re78) kernel ate
more
film re78 treated age black hispanic married educ nodegree re75, ate
more
qui regress re78 treated##c.age treated##black treated##hispanic treated##married treated##c.educ treated##nodegree treated##c.re75
more
margins, dydx(treated)
more
margins, dydx(treated) over(treated)
more