倾向得分匹配法(PSM)汇总
本文由计量经济学服务中心发布
转载请注明来源
备注:
1、描述性分析一般主要查看数据结构,建议tabstata或者tabulate查看
2、PSM数据分为截面数据与面板数据等;截面数据:参加培训是否有助于获得更高的工资吗?/面板数据(参加工会是否有助于获得更高的工资吗?nlswork.dta)
备注:
1、PSM结果主要汇报Logit回归结果表、变量平衡表、倾向评分得分计算的ATT、ATU、ATE值,较多选择最近邻匹配、半径匹配、核匹配三种分析方法
2、命令代码:psmatch2 $x, out(re78)neighbor(1) ate ties logit common等;
3、pstestx1 x2 x3,both graph,检查变量 x1 x2x3是否平衡了数据,both表示对匹配前后进行进行查看是否匹配,默认只对匹配后的数据显示,4、graph还对各变量匹配前后的平衡情况进行说明,psgraph画出直方图,显示倾向得分的共同取值范围
5、根据匹配后的样本计算平均处理效应,ATT,average treatment effect on the treated
前言
读北大有助于提高收入吗?
读文科有助于成功吗?
读大学究竟有什么用?
经济学中常希望评估某项目或政策实施后的效应,比如政府推出的就业培训项目(job training program)。
此类研究称为“项目效应评估”(program evaluation),而项目效应也称为“处理效应”(treatment effect) ,项目参与者的全体构成“实验组”或“处理组”(treatment group,或 the treated),而未参与项目者则构成“控制组” (control group)或“对照组”考虑就业培训的处理效应评估。
一个天真的做法是直接对比实验组与控制组的未来收入或就业状况。但参加就业培训者的未来收入比未参加者通常更低。难道就业培训反而有害?-是否参加培训是参加者自我选择(self selection)的结果,岗位好收入。
一、命令介绍
Stata does not have a built-in command for propensity score matching, a non-experimental method of sampling that produces a control group whose distribution of covariates is similar to that of the treated group. However, there are several user-written modules for this method. The following modules are among the most popular:
Stata没有一个内置的倾向评分匹配的命令,一种非实验性的抽样方法,它产生一个控制组,它的协变量分布与被处理组的分布相似。但是,这个方法有几个用户编写的模块。以下是最受欢迎的模块(主要有如下几个外部命令)
psmatch2.ado
pscore.ado
nnmatch.ado
psmatch2.ado was developed by Leuven and Sianesi (2003) and pscore.ado by Becker and Ichino (2002). More recently, Abadie, Drukker, Herr, and Imbens (2004) introduced nnmatch.ado. All three modules support pair-matching as well as subclassification.
You can find these modules using the .net command as follows:
net search psmatch2
net search pscore
net search nnmatch
You can install these modules using the .ssc or .net command, for example:
ssc install psmatch2, replace
After installation, read the help files to find the correct usage, for example:
help psmatch2
上述主要介绍了如何获得PSM相关的命令,总结一下目前市面上用的较好的命令为psmatch2.
PSM 相关命令
help psmatch2
help nnmatch
help psmatch
help pscore
持续获取最新的 PSM 信息和程序
findit propensity score
findit matching
psmatch2 is being continuously improved and developed. Make sure to keep your version up-to-date as follows
ssc install psmatch2, replace
where you can check your version as follows:
which psmatch2
语法格式
help psmatch2
psmatch2 depvar [indepvars] [if exp] [in range] [, outcome(varlist)
pscore(varname) neighbor(integer) radius caliper(real)
mahalanobis(varlist) ai(integer) population altvariance
kernel llr kerneltype(type) bwidth(real) spline
nknots(integer) common trim(real) noreplacement
descending odds index logit ties quietly w(matrix) ate]
where indepvars and mahalanobis(varlist) may contain factor variables;
see fvvarlist.
psmatch2 D x1 x2 x3, outcome(y)
pscore(varname) neighbor(integer) radius caliper(real)
mahalanobis(varlist) ai(integer) population altvariance
kernel llr kerneltype(type) bwidth(real) spline
nknots(integer) common trim(real) noreplacement
descending odds index logit ties quietly w(matrix) ate]
核匹配 (Kernel matching)
其他匹配方法
广义精确匹配(Coarsened Exact Matching) || help cem
局部线性回归匹配 (Local linear regression matching)
样条匹配 (Spline matching)
马氏匹配 (Mahalanobis matching)
二、PSM 应用举例: 参加培训是否有助于获得更高的工资吗?
数据介绍 :Data used by Lalonde (1986)We are interested in the possible effect of participation in a job training program on individuals earnings in 1978This dataset has been used by many authors ( Abadie et al. 2004,Becker and Ichino, 2002, Dehejia and Wahba, 1999).
三、PSM dofile
stata code
logfile :
log using E:\stata\personal18\高级计量经济学\A15-psm\2017年计量经济学服务中心psm.log, text replace // log_-begin-__
shellout "E:\stata\personal18\高级计量经济学\A15-psm\Grilli_PSM计量经济学服务中心.pdf"
cd E:\stata\personal18\maindata //设置工作路径,调用数据
use "计量经济学服务中心psm.dta", clear //打开cd设置工作路径下面的数据
desc
tabulate t, summarize(re78) means standard
reg re78 t,r
We should conclude that the treatment is dangerous because the expected average earning for treated is lower than for control! Is this a reliable result?
Let us include all the pre-treatment variables available in the data set as independent variables
reg re78 t age edu black hisp married re74 re75 u74 u75,r
est store 多元PSM
esttab 多元PSM using 计量经济学服务中心psm.rtf, mtitles("多元PSM" ) ///
title("This is the regression table") ///
append star( * 0.10 ** 0.05 *** 0.01 ) staraux r2 nogaps
The estimated effect of training is positive (+1672 dollars) and it is statistically significant
set seed 20180105
gene ranorder=runiform()
order ranorder
gen u=runiform()
sort u
order u
local v1 "t"
local v2 "age edu black hisp married re74 re75 u74 u75"
global x "`v1' `v2' "
psmatch2 $x, out(re78) neighbor(1) ate ties logit common // 1:1 匹配
psmatch2 $x, out(re78) neighbor(1) ate ties logit common // 1:1 匹
pstest $v2, both graph
psgraph
log close
shellout E:\stata\personal18\高级计量经济学\A15-psm\计量经济学服务中心psm.log
结果展示 :
▍推荐阅读: