sysuse nlsw88, clear drop if union == . rsort, seed(135) id(idcode) keep in 1/200 gen id123 = _n local mx "age race collgrad married industry" local treat "union" keep id123 `mx' `treat' hours wage ccmatch `mx', cc(`treat') id(id123) //按照年龄、种族、是否上大学、婚姻状况以及所属行业进行精确匹配 keep if match!=. //保留有匹配的观测值 gsort match -union //按照配对数升序、工会与否降序排列 list, sepby(match)
+-------------------------------------------------------+ 1. | age | race | married | collgrad | | 34 | white | single | not college grad | |-------------------------------------------------------| | industry | union | wage | id123 | | Transport/Comm/Utility | union | 14.51691 | 119 | |-------------------------+-----------------------------| | match | match_id | | 1 | 108 | +-------------------------------------------------------+
+-------------------------------------------------------+ 2. | age | race | married | collgrad | | 34 | white | single | not college grad | |-------------------------------------------------------| | industry | union | wage | id123 | | Transport/Comm/Utility | nonunion | 15.48309 | 108 | |-------------------------+-----------------------------| | match | match_id | | 1 | 119 | +-------------------------------------------------------+
*……省略中间15对
+-------------------------------------------------------+ 33. | age | race | married | collgrad | | 45 | white | single | college grad | |-------------------------------------------------------| | industry | union | wage | id123 | | Professional Services | union | 17.02898 | 149 | |-------------------------+-----------------------------| | match | match_id | | 17 | 138 | +-------------------------------------------------------+
+-------------------------------------------------------+ 34. | age | race | married | collgrad | | 45 | white | single | college grad | |-------------------------------------------------------| | industry | union | wage | id123 | | Professional Services | nonunion | 8.518515 | 138 | |-------------------------+-----------------------------| | match | match_id | | 17 | 149 | +-------------------------------------------------------+
同样,我们也拿 Stata 自带的美国妇女 1988 年工资数据进行演示,然后与
ccmatch
产生的结果进行对比:
sysuse nlsw88, clear drop if union==. rsort, seed(135) id(idcode) keep in 1/200 gen id123 = _n local exactX "race collgrad married industry" local treat "union" tostring `exactX', replace force keep id123 `exactX' `treat' age wage vmatch `treat', gen(nmatch) /// show(id123) /// save(nlsw_vmatch) first /// devia(age 0) ///按照年龄进行精确匹配 strng(`exactX') ///按照种族、是否大学毕业、婚姻状况以及所属行业进行精确匹配
drop if nmatch == 0 | nmatch == . list *- nmatch == 0: Treat 组中没有找到匹配对象的观察值; *- nmatch == .: Control 组中没有被使用的观察值;
sysuse nlsw88, clear drop if union==. rsort, seed(135) id(idcode) keep in 1/200 gen id123 = _n local exactX "race collgrad married industry" local treat "union" tostring `exactX', replace force keep id123 `exactX' `treat' age wage vmatch `treat', gen(nmatch) /// show(id123) /// save(nlsw_vmatch) first /// devia(age 3) ///按照年龄进行近邻匹配,允许3的差距 strng(`exactX') ///按照种族、是否大学毕业、婚姻状况以及所属行业进行精确匹配
drop if nmatch==0|nmatch==. list *- nmatch==0: Treat 组中没有找到匹配对象的观察值; *- nmatch==.: Control 组中没有被使用的观察值;
*-Setup *-Cattaneo (2010) *Efficient semiparametric estimation of multi-valued treatment effects under ignorability. Journal of Econometrics 155: 138–154. *A study of the effect of a mother’s smoking status during pregnancy (mbsmoke) on infant birthweight (bweight)
*数据地址:https://gitee.com/arlionn/data/blob/master/data01/cattaneo2.dta use "https://gitee.com/arlionn/data/raw/master/data01/cattaneo2.dta", clear des2
*-Estimate the average treatment effect of mbsmoke on bweight *-Match on two continuous variables, mage and fage *-Require exact matches on the binary variables *-Use the bias-adjusted estimator
不同于 1、2 号学生最终进入了私立大学,3 号学生选择进入公立大学,这就给了我们识别因果效应的绝佳机会,即只要比较组 A 学生之间的收入差异,就可以识别出私立大学教育产生的收益。当然,在组 A 中进行的比较,只是众多匹配比较中的一个,我们需要更多的样本与信息来估计私立大学的收入优势。建立如下回归模型: