查看原文
其他

倾向得分匹配法(PSM)汇总

大秦学术 数量经济学 2022-07-01

本文由计量经济学服务中心发布

转载请注明来源


284位学友已经对《读北大有助于提高收入吗?重磅推荐学习倾向匹配得分(另附dofile免费获取)》一文进行学习了,经过小编苦苦央求,现在决定与大家分享。


吾生也有涯,而学无涯!


全文后面提供的dofile里面涉及了log、shellout、local、global、des、reg、esttab、pamatch2等命令,涉及的知识点非常多,欢迎收藏阅读,若是对哪一块命令有一文,可以留言交流!


stata:倾向得分匹配(PSM)


双重差分倾向得分匹配(PSM-DID)

读北大有助于提高收入吗?重磅推荐学习倾向匹配得分(另附dofile免费获取)


读北大有助于提高收入吗?


读文科有助于成功吗? 


读大学究竟有什么用?


经济学中常希望评估某项目或政策实施后的效应,比如政府推出的就业培训项目(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


结果展示 :


推荐阅读:

研究生可以问导师的八件事,也是指导教师会帮你做的八件事

一文搞定毕业论文开题到答辩(数据文献、word排版、答辩PPT)全部技巧

如果你硕士很出色,博士也很出色,那你就会一直很出色

2017中国最好学科排名正式发布!

南大核心CSSCI官网发布最新名单!

您可能也对以下帖子感兴趣

文章有问题?点此查看未经处理的缓存