a6 did - printed on 2018/5/22 16:57:07 1 2 · a6_did - printed on 2018/5/22 16:57:07 page 2 65 *...

23
A6_DID - Printed on 2018/5/22 16:57:07 Page 1 1 2 * -------------------------------------------------- 3 * 4 * $$$$$ $$$$$$$$ $ $$$$$$$$ $ 5 * $$ $$ $ $$ $ $$ $ $$ $ $$ 6 * $$ $ $$ $$$ $$ $$$ 7 * $$$ $$ $ $$ $$ $ $$ 8 * $$$ $$ $ $$ $$ $ $$ 9 * $$$ $$ $$$$$ $$ $$$$$ 10 * $ $$ $$ $ $$ $$ $ $$ 11 * $$ $$ $$ $ $$ $$ $ $$ 12 * $$$$$ $$$$ $$$ $$$$ $$$$ $$$ $$$$ 13 * 14 * -------------------------------------------------- 15 * 16 * _________________________________________ 17 * ————————————————————————————————————————— 18 * Stata () 19 * 20 * (2018.1.13-2018.1.16) 21 * 22 * QQ: 122160188 (Stata--2018) 23 * _________________________________________ 24 * ————————————————————————————————————————— 25 * 26 * 27 * 主:连28 * 29 * 位:中30 * : [email protected] 31 * 页:http://www.lingnan.sysu.edu.cn/lnshizi/faculty_vch.asp?tn=50 32 * : http://www.jianshu.com/u/69a30474ef33 33 * 博:http://weibo.com/arlionn 34 * 程:http://www.peixun.net/author/3.html 35 36 * 信:lianyj45 37 * 公群:Stata(微信: StataChina) 38 39 40 41 42 * ========================== 43 * 第主 44 * Difference-in-Difference 45 * ========================== 46 * 47 48 49 *-注:执执,请请执执请请执50 global path "`c(sysdir_personal)'\PX_A_2018a\A6_DID" //定课程51 global D "$path\data" //52 global R "$path\refs" //53 global Out "$path\out" //结:图54 adopath + "$path\adofiles" //自程55 cd "$D" 56 set scheme s2color 57 58 59 * ------------------ 60 * ---- 本主定---- 61 * ------------------ 62 63 * 6.2 D-in-D 64 * 6.3 D-in-D 的倍

Upload: others

Post on 27-Oct-2019

4 views

Category:

Documents


0 download

TRANSCRIPT

A6_DID - Printed on 2018/5/22 16:57:07

Page 1

1 2 * -------------------------------------------------- 3 * 4 * $$$$$ $$$$$$$$ $ $$$$$$$$ $ 5 * $$ $$ $ $$ $ $$ $ $$ $ $$ 6 * $$ $ $$ $$$ $$ $$$ 7 * $$$ $$ $ $$ $$ $ $$ 8 * $$$ $$ $ $$ $$ $ $$ 9 * $$$ $$ $$$$$ $$ $$$$$

10 * $ $$ $$ $ $$ $$ $ $$ 11 * $$ $$ $$ $ $$ $$ $ $$ 12 * $$$$$ $$$$ $$$ $$$$ $$$$ $$$ $$$$ 13 * 14 * -------------------------------------------------- 15 * 16 * _________________________________________ 17 * ————————————————————————————————————————— 18 * Stata 研研研 (初初) 19 * 北北 20 * (2018.1.13-2018.1.16) 21 * 22 * QQ群群: 122160188 (Stata-连连连-2018寒寒) 23 * _________________________________________ 24 * ————————————————————————————————————————— 25 * 26 * 27 * 主主主:连连连 28 * 29 * 单 位:中中中中中中中中中中中 30 * 电 邮: [email protected] 31 * 主 页:http://www.lingnan.sysu.edu.cn/lnshizi/faculty_vch.asp?tn=50 32 * 简 书: http://www.jianshu.com/u/69a30474ef33 33 * 微 博:http://weibo.com/arlionn 34 * 课 程:http://www.peixun.net/author/3.html 35 36 * 微 信:lianyj45 37 * 公公群:Stata连连连(微信: StataChina) 38 39 40 41 42 * ========================== 43 * 第第主 倍倍倍 44 * Difference-in-Difference 45 * ========================== 46 * 47 48 49 *-注注:执执执执执执执执,请请执执请请执执50 global path "`c(sysdir_personal)'\PX_A_2018a\A6_DID" //定定课程定定51 global D "$path\data" //范范范范52 global R "$path\refs" //参参参参53 global Out "$path\out" //结结:图图图图图54 adopath + "$path\adofiles" //自自程自 55 cd "$D"56 set scheme s2color57 58 59 * ------------------60 * ---- 本主定定 ----61 * ------------------62 63 * 6.2 D-in-D 的的的64 * 6.3 D-in-D 的的的的倍

A6_DID - Printed on 2018/5/22 16:57:07

Page 2

65 * 6.4 范范 1: 最最最最倍最最最最最的最最 Card and Krueger (1994)66 * 6.5 范范 2: 新新新新新新新最新新新新的最最 Kiel and McClain (1995)67 * 6.6 多多 DID 与与与与与寒与68 * 6.7 范范 3: 美美美美主倍最(ADA)最最最图最最的最最69 70 71 72 73 *------------------74 *-6.1 倍倍倍简倍 Difference-in-Difference (D-in-D, DID)75 *------------------76 77 shellout "$R\连连连_公公中中研公中的公公公公公.ppt"78 79 *-自自自自公公80 81 *-在在在在、移移、外外外最、82 *-禁禁倍执、禁禁倍执禁83 *-股股股股、交交交交、兼兼兼兼、政政政政84 *-政政 R&D 最资资资资、税兼资资、政税资资85 *-农最资资、户户政户86 87 *-来来 I:个个个个88 *- 哪哪主哪哪哪哪参与在在在在?89 *- 哪哪公公哪哪哪哪哪哪股股股股?90 *91 *-来来 II:时时个个92 *- 即即即即即禁禁执,随随兼随的随随,戒禁的主范戒连戒戒93 *- 即即政政即哪哪R&D最资,企最戒中R&D投随戒投中与投与 94 95 96 *---------- 97 *-主定图PPT 98 99 shellout "$R\diff_cmd.pdf" // diff 执执的命命参命 SJ 16-1

100 shellout "$R\diff_PPT.pdf"101 shellout "$R\DiD_Wooldridge_2007.pdf" //伍连伍主定102 shellout "$R\DiD_Wooldridge_2012.pdf" //伍连伍主定103 shellout "$R\Taber_2012_FE_DID.pdf" //DID与FE的政中104 shellout "$R\Pischke_2005_DID_Lecture.pdf" //即不的主定105 shellout "$R\Waldinger_2012_DID_Lec.pdf" //主的讲讲讲106 107 *-Bertrand, M., E. Duflo, and S. Mullainathan. 2004. 108 * How Much Should We Trust Differences-in-Differences Estimates? 109 * Quarterly Journal of Economics 119 (1):249-275. (讲多很很个很)110 shellout "$R\Bertrand_2004_DID.pdf"111 112 * Nichols, A., 2007, 113 * Causal inference with observational data, 114 * Stata Journal, 7 (4): 507-541.115 shellout "$R\Nichols_2007_SJ_Causal_inference.pdf"116 117 *--------- 118 *-个很119 120 *-刘刘命, 赵赵赵, 2015, 121 * 美国随新国国国国国国很国国国国?——基哪基基基倍的倍的基基, 122 * 管的管管, (8): 30-38.123 shellout "$R\刘刘命_2015_随新国DID.pdf"124 125 *-刘刘命, 赵赵赵, 2016, 126 * 匿匿匿匿匿匿国国国中美的很国中匿匿国?——基哪基基基倍的倍的研公, 127 * 很国中:季季, 6(1): 173-204.128 shellout "$R\刘刘命_2016_匿匿匿匿匿匿_DID_反反哪.pdf" //写的讲写写

A6_DID - Printed on 2018/5/22 16:57:07

Page 3

129 130 *-刘刘命, 赵赵赵, 2015, 131 * 西西中西国:戒增增国增投政户增增——基哪PSM-DID的倍的研公, 132 * 中美最最很国, (6): 32-43. 133 shellout "$R\刘刘命_2015_西西中西国_PSM-DID.pdf"134 135 *-范范范, 刘刘刘, 2015, 136 * 为为新为为为——兼兼新兼税兼兼的兼随倍兼个个, 137 * 管的管管, (5): 18-27.138 shellout "$R\范范范_2015_新兼税兼兼_DDD.pdf"139 140 *-郑新最, 王王, 赵赵赵, 2011, 141 * “省省管省” 能能匿很国戒增国?——基基基倍的倍, 142 * 管的管管, (8): 34-44.143 shellout "$R\郑新最_2011_DID.pdf" //写的讲写写144 145 *-徐徐徐, 王王王, 舒舒, 2007, 146 * 国的地地与很国戒增——来自中美省增, 省省书省交省的基范, 147 * 很国研公, (9): 18-31.148 shellout "$R\徐徐徐_2007_DID.pdf"149 150 *-孙参孙, 白基白, 谢谢初, 2011, 151 * 户户匿匿兼兼最中美农户户国户省国的最最, 152 * 很国研公, (1): 28-41. 153 shellout "$R\孙参孙_2011_DID.pdf" //批批即很DID154 155 *-Nunn, N., N. Qian, 2011, 156 * The potato's contribution to population and urbanization: 157 * Evidence from a historical experiment, 158 * The Quarterly Journal of Economics, 126 (2): 593-650.159 shellout "$R\Nunn_Qian_2011_QJE.pdf"160 161 *-Chhaochharia, V., Y. Grinstein, 162 * CEO compensation and board structure, 163 * The Journal of Finance, 2009, 64(1): 231-261.164 shellout "$R\DiD_Chhaochharia_2009_JF.pdf"165 166 *-Giroud, X., H. M. Mueller, 167 * Does corporate governance matter in competitive industries?, 168 * Journal of Financial Economics, 2010, 95 (3): 312-331.169 shellout "$R\DID_Giroud_2010_JFE.pdf"170 171 *-Fresard, L., 172 * Financial strength and product market behavior: 173 * The real effects of corporate cash holdings, 174 * The Journal of Finance, 2010, 65(3): 1097-1122.175 shellout "$R\DiD_Fresard_2010_JF.pdf"176 177 178 179 *-------------------180 *-6.2 D-in-D 的的的181 182 *---------------183 *-一个简单的范范184 185 use "diff-ex.dta", clear186 187 label define time_lab 0 "Before" 1 "After"188 label value time time_lab189 190 label define train_lab 0 "Control" 1 "Treat"191 label value train train_lab192

A6_DID - Printed on 2018/5/22 16:57:07

Page 4

193 xgroup training time, gen(gg) label lname(gg_lab)194 label list gg_lab195 /*196 gg_lab:197 1 Control Before198 2 Control After199 3 Treat Before200 4 Treat After201 */202 203 *-基本基的倍基204 tabstat wage , by(gg) ///205 s(mean sd min max p25 p50 p75) f(%6.1f) c(s)206 /*207 gg | mean sd min max p25 p50 p75208 ---------------+---------------------------------------------------------209 Control Before | 662.4 318.9 213.3 1391.0 335.0 631.2 911.1210 Control After | 860.0 247.2 286.3 1391.0 631.2 834.7 1064.0211 Treat Before | 1306.6 449.3 468.7 2296.5 856.4 1278.8 1627.0212 Treat After | 1477.0 391.8 656.2 2296.5 1237.4 1462.0 1658.2213 ---------------+---------------------------------------------------------214 Total | 1083.2 489.2 213.3 2296.5 656.2 1054.6 1394.9215 -------------------------------------------------------------------------216 */217 218 *-图图倍基219 220 *-Treatment Group221 #delimit ;222 twoway (kdensity wage if gg==3, lw(*2) lc(black) lp(dash))223 (kdensity wage if gg==4, lw(*2) lc(blue))224 ,225 legend(off)226 text(0.00063 1500 "Treat_Before")227 text(0.00090 1850 "Treat_After")228 title("Treatment Group", box) xtitle("Wage")229 ;230 #delimit cr231 232 *-Control Group233 #delimit ;234 twoway (kdensity wage if gg==1, lw(*2) lc(pink) lp(dash))235 (kdensity wage if gg==2, lw(*2) lc(green))236 ,237 legend(off)238 text(0.00140 180 "Control_Before")239 text(0.00140 1260 "Control_After")240 title("Control Group", box) xtitle("Wage")241 ;242 #delimit cr243 244 *-Combination245 #delimit ;246 twoway (kdensity wage if gg==1, lw(*2) lc(black) lp(dash))247 (kdensity wage if gg==2, lw(*2) lc(blue))248 (kdensity wage if gg==3, lw(*2) lc(pink) lp(dash))249 (kdensity wage if gg==4, lw(*2) lc(green))250 ,251 legend(off)252 text(0.00147 300 "Control_Before")253 text(0.00140 1360 "Control_After")254 text(0.00063 1480 "Treat_Before")255 text(0.00090 1900 "Treat_After")256 xtitle("Wage")

A6_DID - Printed on 2018/5/22 16:57:07

Page 5

257 ;258 #delimit cr259 260 *-均均倍基261 graph bar wage, over(time) over(train)262 graph hbar wage, over(train) over(time)263 264 *-即与倍位不交的基不265 graph bar (p50)wage, over(time) over(train)266 graph bar (p25)wage, over(time) over(train)267 graph bar (p75)wage, over(time) over(train)268 graph bar (p10)wage, over(time) over(train)269 graph bar (p90)wage, over(time) over(train)270 271 272 *-Q: 请如如新 "Training" 最 "Wage" 的最最?273 274 *---------+------------------+----------275 * Group | Pre Post | Diff276 *---------+------------------+---------- 277 * Treat | Y0 Y1 | (Y1-Y0) 时时个个+处的个个278 * | | -279 * Control | C0 C1 | (C1-C0) 时时个个+0280 *---------+------------------+----------281 * Diff | (Y0-C0) (Y1-C1) | D-in-D282 *---------+------------------+----------283 284 * D-in-D = (Y1-Y0)-(N1-N0) 处的个个285 * = (Y1-C1)-(Y0-C0)286 287 *-研兼:288 *289 * (Y1-C1) Right ?290 *291 * Should be: ATE = (Y1-Y0)-(N1-N0) D-in-D292 *293 * ATE: Average Treatment Effect294 295 *-隐隐的一个基隐寒与:时时个个时与(The Same Time-effect Condition)296 *297 * 否否,最就倍省就时就298 *299 * 即不不不寒与时:控匿控批,寻寻兼最寻300 301 302 303 *-----------------------304 *-6.3 D-in-D 的的的的倍305 306 *-的倍1:reg y treat time treat#time 307 *-的倍2:diff308 309 help diff310 311 *-Villa, J M (2016). 312 * diff: Simplifying the estimation of difference-in-differences 313 * treatment effects. 314 * Stata Journal, 16 (1): 52-71.315 shellout "$R\diff_cmd.pdf" // diff 执执的命命参命 SJ 16-1316 317 *-引很引引参引的参引:在"百匿中百"中中随参引的中公即中318 319 diff wage, treated(training) period(time)320

A6_DID - Printed on 2018/5/22 16:57:07

Page 6

321 *-解基:采很采采的的倍322 reg wage if (time==0&train==0), noheader // C0323 *------------------------------------------------324 * wage | Coef. Std. Err. t P>|t| 325 *-------+----------------------------------------326 * _cons | 662.377 10.234 64.72 0.000 327 *------------------------------------------------328 329 reg wage if (time==0&train==1), noheader // Y0330 reg wage train if time==0 , noheader // Y0-C0331 332 reg wage if (time==1&train==0), noheader // C1333 reg wage if (time==1&train==1), noheader // Y1334 reg wage train if time==1 , noheader // Y1-C1335 336 gen tr_x_time = train*time337 reg wage train time tr_x_time, noheader // (Y1-C1)-(Y0-C0)338 339 *----------------------------------------------------------340 * wage | Coef. Std. Err. t P>|t| 341 *-----------+----------------------------------------------342 * training | 644.254 16.302 39.52 0.000 343 * time | 197.586 16.583 11.91 0.000 344 * tr_x_time | -27.204 23.170 -1.17 0.240 345 * _cons | 662.377 11.612 57.04 0.000 346 *----------------------------------------------------------347 348 349 *------350 *-总结: D-in-D 的的的与定351 *352 * --------------------------------------------------------------353 *- y = a0 + a1*Treat + a2*Time + b*TreatxTime + a3*Controls + e 354 * --------------------------------------------------------------355 *356 * 其中,b 的中范的的均最投自的投的隐的 ATE 357 358 *------359 *-如兼:360 *361 *-(1) 绝最基不?增投时最基不(控变的百倍变)? 兼最?362 *363 *-(2) 干干干干?控匿控批的隐戒随364 *365 *-(3) 均均变均投否均的?即很的主群在 Treat 中的中赵程匿投即与的 366 * 倍位范367 368 369 *------------370 *-6.4 范范 1: 最最最最倍最最最最最的最最 Card and Krueger (1994)371 *------------372 373 *-We use the dataset form Card&Krueger (1994)374 * Card, D., A. B. Krueger, 1994, 375 * Minimum Wages and Employment: 376 * A Case Study of the Fast-Food Industry 377 * in New Jersey and Pennsylvania, 378 * American Economic Review, 84 (4): 772-793. 379 * http://emlab.berkeley.edu/users/card/data_sets.html (完完范范参命)380 381 shellout "$R\Card_1994_AER_DID.pdf" // Card(1994) 的参382 shellout "$R\Waldinger_2012_DID_Lec.pdf" // PPT, pp.12-22383 shellout "$R\DiD_Card_2013_AER_JEEA.pdf" //最新兼参384

A6_DID - Printed on 2018/5/22 16:57:07

Page 7

385 *-背背:386 * On April 1, 1992, New Jersey's minimum wage 387 * rose from $4.25 to $5.05 per hour. 388 389 *-定的:390 * To evaluate the impact of the law we surveyed 391 * 410 fast-food restaurants 392 * in New Jersey and eastern Pennsylvania before and after the rise.393 394 *-结兼:395 * Find no evidence that the rise in the min-wage reduced employment.396 397 398 *------ 399 *-6.4.1 基本基的倍基400 401 use "$D\cardkrueger1994.dta", clear402 des403 404 * Contains data from ...\PX_A_2018a\A6_DID\data\cardkrueger1994.dta405 * obs: 820 Dataset from Card&Krueger (1994)406 * vars: 8 27 May 2011 20:36407 * size: 12,300 408 * ------------------------------------------------------------409 * value410 * variable name label variable label411 * ------------------------------------------------------------412 * id Store ID413 * t Feb. 1992 = 0; Nov. 1992 = 1414 * treated treated New Jersey = 1; Pennsylvania = 0415 * fte Output: Full Time Employment416 * bk Burger King == 1417 * kfc Kentuky Fried Chiken == 1418 * roys Roy Rogers == 1419 * wendys Wendy's == 1420 * ------------------------------------------------------------421 * Sorted by: id t422 423 sum424 * Variable | Obs Mean Std. Dev. Min Max425 * ----------+-------------------------------------------426 * id | 820 246.5073 148.1413 1 522427 * t | 820 .5 .5003052 0 1428 * treated | 820 .8073171 .3946469 0 1429 * fte | 801 17.59457 9.022517 0 80430 * bk | 820 .4170732 .4933761 0 1431 * ----------+-------------------------------------------432 * kfc | 820 .195122 .3965364 0 1433 * roys | 820 .2414634 .4282318 0 1434 * wendys | 820 .1463415 .3536639 0 1435 436 *-------------437 *-基本图图倍基438 439 label define time_lab 0 "Before" 1 "After"440 label value t time_lab441 label define train_lab 0 "C_Psy" 1 "T_NJ"442 label value treated train_lab443 xgroup treated t, gen(gg) label lname(gg_lab)444 label list gg_lab445 446 447 *------ 448 *-6.4.2 基本采采倍基

A6_DID - Printed on 2018/5/22 16:57:07

Page 8

449 450 diff fte, t(treated) period(t)451 452 /*453 DIFFERENCE-IN-DIFFERENCES ESTIMATION RESULTS454 Number of observations in the DIFF-IN-DIFF: 801455 Before After 456 Control: 78 77 155457 Treated: 326 320 646458 404 397459 --------------------------------------------------------460 Outcome var. | fte | S. Err. | |t| | P>|t|461 ----------------+---------+---------+---------+---------462 Before | | | | 463 Control | 19.949 | | | 464 Treated | 17.065 | | | 465 Diff (T-C) | -2.884 | 1.135 | -2.54 | 0.011**466 After | | | | 467 Control | 17.542 | | | 468 Treated | 17.573 | | | 469 Diff (T-C) | 0.030 | 1.143 | 0.03 | 0.979470 | | | | 471 Diff-in-Diff | 2.914 | 1.611 | 1.81 | 0.071*472 --------------------------------------------------------473 R-square: 0.01474 * Means and Standard Errors are estimated by linear regression475 **Inference: *** p<0.01; ** p<0.05; * p<0.1476 */477 478 diff fte, t(treated) period(t) bs rep(500) // Bootstrap 中标标479 *-Note: 每每每每的中标标中能每每基不480 set seed 13579481 diff fte, t(treated) period(t) bs rep(500) // 每每的结结每时与482 483 *-自执自写执执484 gen treat_x_time = treated*t485 reg fte treated t treat_x_time486 reg fte treated t treat_x_time, robust487 reg fte treated t treat_x_time, vce(bs, reps(500))488 *-Note: 好处,便哪即很 esttab 执执中外结结489 * -------------------------------------------------------490 * | Observed Bootstrap 491 * fte | Coef. Std. Err. z P>|z| 492 * -------------+-----------------------------------------493 * treated | -2.884 1.417 -2.03 0.042 494 * t | -2.407 1.612 -1.49 0.135 495 * treat_x_time | 2.914 1.745 1.67 0.095 496 * _cons | 19.949 1.366 14.60 0.000 497 * -------------------------------------------------------498 499 500 *------ 501 *-6.4.3 包隐控匿控批的 D-in-D502 503 diff fte, t(treated) p(t) cov(bk kfc roys)504 505 diff fte, t(treated) p(t) cov(bk kfc roys) report506 507 diff fte, t(treated) p(t) cov(bk kfc roys) report bs reps(300)508 509 *-采采结结回徐510 diff fte, t(treated) p(t)511 est store m0512 diff fte, t(treated) p(t) cov(bk kfc roys)

A6_DID - Printed on 2018/5/22 16:57:07

Page 9

513 est store m1514 diff fte, t(treated) p(t) cov(bk kfc roys) bs reps(300)515 est store m1_bs516 517 local m "m0 m1 m1_bs"518 esttab `m', mtitle(`m') nogap star(* 0.1 ** 0.05 *** 0.01)519 /*520 -----------------------------------------------------521 (1) (2) (3) 522 m0 m1 m1_bs 523 -----------------------------------------------------524 t -2.407* -2.403* -2.403* 525 (-1.66) (-1.83) (-1.77) 526 treated -2.884** -2.324** -2.324* 527 (-2.54) (-2.25) (-1.94) 528 _diff 2.914* 2.935** 2.935** 529 (1.81) (2.01) (2.05) 530 bk 0.917 0.917 531 (1.03) (0.89) 532 kfc -9.205*** -9.205***533 (-9.15) (-9.56) 534 roys -0.897 -0.897 535 (-0.93) (-0.82) 536 _cons 19.95*** 21.16*** 21.16***537 (19.57) (18.53) (16.43) 538 -----------------------------------------------------539 N 801 801 801 540 -----------------------------------------------------541 t statistics in parentheses542 * p<0.1, ** p<0.05, *** p<0.01543 */544 545 546 *-省就采很 reg 执执执执 OLS 采采547 reg fte treated t treat_x_time548 est store r0549 reg fte treated t treat_x_time bk kfc roys550 est store r1551 reg fte treated t treat_x_time bk kfc roys, vce(bs, reps(500))552 est store r1_bs553 554 local m "r0 r1 r1_bs"555 esttab `m', mtitle(`m') s(r2 N) nogap star(* 0.1 ** 0.05 *** 0.01)556 /*557 ------------------------------------------------------------558 (1) (2) (3) 559 r0 r1 r1_bs 560 ------------------------------------------------------------561 treated -2.884** -2.324** -2.324* 562 (-2.54) (-2.25) (-1.72) 563 t -2.407* -2.403* -2.403 564 (-1.66) (-1.83) (-1.61) 565 treat_x_time 2.914* 2.935** 2.935* 566 (1.81) (2.01) (1.79) 567 bk 0.917 0.917 568 (1.03) (1.00) 569 kfc -9.205*** -9.205***570 (-9.15) (-10.19) 571 roys -0.897 -0.897 572 (-0.93) (-0.87) 573 _cons 19.95*** 21.16*** 21.16***574 (19.57) (18.53) (15.25) 575 ------------------------------------------------------------576 r2 0.00805 0.188 0.188

A6_DID - Printed on 2018/5/22 16:57:07

Page 10

577 N 801 801 801 578 ------------------------------------------------------------579 t statistics in parentheses580 * p<0.1, ** p<0.05, *** p<0.01581 */582 583 584 585 *------ 586 *-6.4.4 PSM 兼最的 D-in-D Kernel PSM Diff-in-Diff.587 588 *-个很参参: 589 * Gorg, H., E. Strobl, 2007, 590 * The effect of R&D subsidies on private R&D, 591 * Economica, 74 (294): 215-234. 592 593 shellout "$R\Gorg_2007_DID.pdf" // PDF 的参594 595 use cardkrueger1994, clear596 diff fte, t(treated) p(t) cov(bk kfc roys) kernel id(id)597 /*598 DIFFERENCE-IN-DIFFERENCES ESTIMATION RESULTS599 Number of observations in the DIFF-IN-DIFF: 800600 Before After 601 Control: 78 76 154602 Treated: 326 320 646603 404 396604 --------------------------------------------------------605 Outcome var. | fte | S. Err. | |t| | P>|t|606 ----------------+---------+---------+---------+---------607 Before | | | | 608 Control | 20.040 | | | 609 Treated | 17.065 | | | 610 Diff (T-C) | -2.975 | 0.941 | -3.16 | 0.002***611 After | | | | 612 Control | 17.449 | | | 613 Treated | 17.573 | | | 614 Diff (T-C) | 0.124 | 0.949 | 0.13 | 0.896615 | | | | 616 Diff-in-Diff | 3.099 | 1.336 | 2.32 | 0.021**617 --------------------------------------------------------618 R-square: 0.02619 * Means and Standard Errors are estimated by linear regression620 **Inference: *** p<0.01; ** p<0.05; * p<0.1621 */622 623 diff fte, t(treated) p(t) cov(bk kfc roys) kernel id(id) support624 diff fte, t(treated) p(t) cov(bk kfc roys) kernel id(id) report625 diff fte, t(treated) p(t) report kernel id(id) ///626 ktype(gaussian) pscore(_ps)627 628 *-Balanced test629 630 *-基本基基:631 * 投所 Balance,投是 Treat 执执之个寻的之之时之632 633 *-核核兼634 cap drop u635 gen u = uniform()636 sort u637 global xx "bk kfc roys t"638 psmatch2 treated $xx if t==0, kernel out(fte) // pre-treatment639 640 *-核兼执执解匹控批的基不最变

A6_DID - Printed on 2018/5/22 16:57:07

Page 11

641 pstest $xx, graph642 *-Note: 本范中,控匿控批每投 0/1 控批,Balanced test 讲很很个643 * 在 4.5 节中的股股股股范范中,个结均好。644 * -------------------------------------------------------645 * | Mean | t-test 646 * Variable | Treated Control %bias | t p>|t| 647 * ------------+--------------------------+---------------648 * bk | .40798 .46789 -12.1 | -1.54 0.123 649 * kfc | .20859 .1444 16.6 | 2.15 0.032 650 * roys | .25153 .27167 -4.7 | -0.58 0.559 651 * t | 0 0 . | . . 652 * -------------------------------------------------------653 654 *-研公与的+结结回徐655 shellout "$R\Girma_2007_DID_PSM.pdf"656 657 658 *------ 659 *-6.4.5 倍位范 D-in-D (Quantile Diff-in-Diff)660 661 *-详写国详详程参详:662 * Athey, S., G. W. Imbens, 2006, 663 * Identification and Inference in 664 * Nonlinear Difference-in-Differences Models, 665 * Econometrica, 74 (2): 431-497. 666 667 shellout "$R\Athey_Imbens_2006.pdf" // QDID 国详详程668 shellout "$R\Alan_2005_QDID.pdf" // QDID 个很669 670 use "cardkrueger1994.dta", clear671 diff fte, t(treated) p(t) qdid(0.25)672 * --------------------------------------------------------673 * Outcome var. | fte | S. Err. | |t| | P>|t|674 * ----------------+---------+---------+---------+---------675 * Before | | | | 676 * Control | 12.500 | | | 677 * Treated | 11.000 | | | 678 * Diff (T-C) | -1.500 | 1.584 | -0.95 | 0.344679 * After | | | | 680 * Control | 11.500 | | | 681 * Treated | 11.500 | | | 682 * Diff (T-C) | 0.000 | 1.658 | 0.00 | 1.000683 * | | | | 684 * Diff-in-Diff | 1.500 | 2.293 | 0.65 | 0.513685 * --------------------------------------------------------686 687 diff fte, t(treated) p(t) qdid(0.50)688 689 diff fte, t(treated) p(t) qdid(0.75)690 * --------------------------------------------------------691 * Outcome var. | fte | S. Err. | |t| | P>|t|692 * ----------------+---------+---------+---------+---------693 * Before | | | | 694 * Control | 25.000 | | | 695 * Treated | 20.500 | | | 696 * Diff (T-C) | -4.500 | 1.214 | -3.71 | 0.000***697 * After | | | | 698 * Control | 22.500 | | | 699 * Treated | 22.500 | | | 700 * Diff (T-C) | 0.000 | 1.217 | 0.00 | 1.000701 * | | | | 702 * Diff-in-Diff | 4.500 | 1.719 | 2.62 | 0.009***703 * --------------------------------------------------------704

A6_DID - Printed on 2018/5/22 16:57:07

Page 12

705 diff fte, t(treated) p(t) qdid(0.50) cov(bk kfc roys)706 diff fte, t(treated) p(t) qdid(0.50) cov(bk kfc roys) kernel id(id)707 708 *-采回回执的 Wage 范范709 use "diff-ex.dta", clear710 diff wage, treated(train) period(time) qdid(0.25)711 diff wage, treated(train) period(time) qdid(0.50)712 diff wage, treated(train) period(time) qdid(0.75)713 *-最兼随低低在在中中赵国714 *-中禁的中每中中的最最715 *-随兼随低反为中每国高高最最716 717 *-ex: 718 shellout "$R\econ4136seminar09_selection_did-solutions.pdf"719 720 721 *----------- 722 *-6.5 范范 2: 新新新新新新新最新新新新的最最 Kiel and McClain (1995)723 *-----------724 725 * K.A. Kiel and K.T. McClain (1995), 726 * House Prices During Siting Decision Stages: 727 * The Case of an Incinerator from Rumor Through Operation,728 * Journal of Environmental Economics and Management 28, 241-255.729 730 shellout "$R\KielMc_1995_DID.pdf" //PDF 的参731 shellout "$R\Kiel_McLain_1995_PPT.pdf" //PPT732 733 *-公公背背: 麻省北麻多麻交(North Andover), 位哪位位位北西 20范英;734 * 1978年研兼新与一个新的新新新新新, 位哪 NA 西北西;735 * 1981年初与与年年个年年年国年年736 * 传传多: 1974-1980 || 新与多: 1981-1984 || 交上-运运: 1985-1992737 738 *-标自准哪基: 739 * 每哪新范有有新新新新新,每哪新范有每变均有;740 * 冲冲(新建新新建反命)投外公的,干为因有因移兼即的隐因;741 742 *-的原范范: 2593个国个, 由哪税兼,城交城外禁的高的基不,仅参仅 NA 交的因移 743 *-范范数数 (1范英=0.3米; 1米=3.3范英)744 745 use "kielmc.dta", clear746 des //范范数数747 /*748 Contains data from kielmc.dta749 obs: 321 The file contains data on houses sold in 1978 or750 1981 in North Andover; Massachu751 vars: 25 13 Dec 2015 12:31752 size: 32,100 (_dta has notes)753 -------------------------------------------------------------------754 755 variable name variable label756 -------------------------------------------------------------------757 year 1978 or 1981758 age age of house759 agesq age^2760 nbh neighborhood #, 1 to 6761 cbd dist. to central bus. dstrct, feet762 intst dist. to interstate, feet763 lintst log(intst)764 price selling price765 rooms # rooms in house766 area square footage of house767 land square footage lot768 baths # bathrooms

A6_DID - Printed on 2018/5/22 16:57:07

Page 13

769 dist dist. from house to incinerator, feet770 ldist log(dist)771 wind perc. time wind incin. to house772 lprice log(price)773 y81 =1 if year == 1981774 larea log(area)775 lland log(land)776 y81ldist y81*ldist777 lintstsq lintst^2778 nearinc =1 if dist <= 15840779 y81nrinc y81*nearinc780 rprice price, 1978 dollars781 lrprice log(rprice)782 -------------------------------------------------------------------783 */784 785 tabulate year786 * | Freq. Percent Cum.787 * --------+--------------------------------788 * 1978 | 179 55.76 55.76789 * 1981 | 142 44.24 100.00790 * --------+--------------------------------791 * Total | 321 100.00792 793 tabulate nearinc //near Incinerator(新新新新新), <4.8km 取1794 * =1 if dist |795 * <= 15840 | Freq. Percent Cum.796 * ------------+--------------------------------797 * 0 | 225 70.09 70.09798 * 1 | 96 29.91 100.00799 * ------------+--------------------------------800 * Total | 321 100.00801 802 gen y81_x_nearinc = y81*nearinc //兼公交产产803 804 did3 rprice nearinc y81, format(%10.2f) //列列DID图图805 /*806 y81=0 y81=1 Difference807 nearinc=1 63692.86 70619.24 6926.38808 SE 5708.97 5505.02 8205.03809 810 nearinc=0 82517.23 101307.51 18790.29811 SE 1878.28 2944.81 3382.63812 813 Difference -18824.37 -30688.27 -11863.90814 SE 4744.59 5827.71 7456.65815 */816 817 *-基本采采倍基818 reg rprice nearinc if y81==0819 est store Before820 821 reg rprice nearinc if y81==1822 est store After823 824 reg rprice nearinc y81 y81_x_nearinc825 est store DID_sim826 827 local cx "age agesq intst land area rooms baths" //控匿控批828 reg rprice nearinc y81 y81_x_nearinc `cx'829 est store DID_control830 831 *-回徐结结832 local m "Before After DID_sim DID_control"

A6_DID - Printed on 2018/5/22 16:57:07

Page 14

833 esttab `m', mtitle(`m') nogap b(%10.2f) t(%3.2f) s(r2 r2_a N) ///834 star(* 0.1 ** 0.05 *** 0.01)835 836 ----------------------------------------------------------------------------837 (1) (2) (3) (4)838 Before After DID_sim DID_control839 ----------------------------------------------------------------------------840 nearinc -18824.37*** -30688.27*** -18824.37*** 3780.33841 (-3.97) (-5.27) (-3.86) (0.85)842 y81 18790.29*** 13928.48***843 (4.64) (4.98)844 y81_x_nearinc -11863.90 -14177.93***845 (-1.59) (-2.84)846 age -739.45***847 (-5.64)848 agesq 3.45***849 (4.25)850 intst -0.54***851 (-2.74)852 land 0.14***853 (4.55)854 area 18.09***855 (7.84)856 rooms 3304.23**857 (1.99)858 baths 6977.32***859 (2.70)860 _cons 82517.23*** 101307.51*** 82517.23*** 13807.67861 (31.09) (32.75) (30.26) (1.24)862 ----------------------------------------------------------------------------863 r2 0.08 0.17 0.17 0.66864 r2_a 0.08 0.16 0.17 0.65865 N 179.00 142.00 321.00 321.00866 ----------------------------------------------------------------------------867 t statistics in parentheses868 * p<0.1, ** p<0.05, *** p<0.01869 870 871 *------872 *-研兼:与 DID 个结时之的的倍873 874 shellout "$R\KielMc_1995_DID.pdf" //PDF 的参, Table3875 876 *-Notes:877 * 的参兼原采很 DID, 878 * Table3: 倍时分采采,基不政注 LN(DIST) 控批的中范控变; 879 * 中可命命在 1981年(产定项项项国) 执执, Control寻与Treat寻投每与与与与的;880 * Table4: 混均采采,戒随时分加加控批与LN(DIST)的交产产;881 882 883 884 885 *-----------------------------886 *-6.6 多多 DID 与与与与与寒与887 *-----------------------------888 889 *-范范隐数: Treat 哪哪执之年可交的范范,Treat 哪哪执一年可交的范范;890 891 *-定的: (1) 中可可基 Common Trend 寒与投否均的; 892 * (2) 每资哪如的政户的增多个结893 894 *-寒与假本国时为 Year[1987-1996], Treat 国公在 1992 年,895 * 896 * Before[1987-1991] After[1993-1996]

A6_DID - Printed on 2018/5/22 16:57:07

Page 15

897 * ---------------------- ----------------------898 * Pre-treatment years Post-treatment years899 * 900 *-的的与定:901 * ----------------------------------------------------------------902 *- y = a0 + a1*Treat + a2*Years + b*Treat#Years + a3*Controls + e 903 * ----------------------------------------------------------------904 *-905 *-Notes:906 *907 * [1] Years: 图列一中列 Year dummies--(yr1988, yr1989, ..., yr1996)908 * [2] Treat#Years: 图列 Treat 与 Year dummies 的交产产909 * [3] 根范 Common Trend 寒与,个不应多:910 * Treat#yr1988, Treat#1989..., Treat#yr1991 的中范每即的的;911 * [4] 若政户的个结投的的的,否 912 * Treat#yr1992, Treat#yr1993, ...., Treat#yr1996 至至每一个投的的的,913 * 资低政均的的. 914 915 916 917 *------------918 *-6.7 范范 3: 美美美美主倍最(ADA)最最最图最最的最最919 920 * Acemoglu et al.(2001, JPE) 921 *----------------------------------------------------922 * Acemoglu, D., Joshua D. Angrist, 2001, 923 * Consequences of employment protection? 924 * The case of the americans with disabilities act, 925 * Journal of Political Economy, 109(5): 915-957. 926 *----------------------------------------------------927 928 929 *-!! 之特命命: 执执执执范范执执执执,请外请请执执请高引执执执!930 cd "$path\Acemoglu_2001_JPE_DID" //不范范投在参命该931 pwd932 933 shellout "Acemoglu_2001_JPE.pdf" //PDF的参934 shellout "Acemoglu_2001_PPT.ppt" //PPT (尚的写变) 935 shellout "Burkhauser_2004_argue.pdf" //反反936 shellout "Thompkins_2013_DID.pdf" //有多参参937 938 *-作低随年的范范图 SAS 程自参命:939 view browse "http://economics.mit.edu/faculty/acemoglu/data/aa2001"940 view browse "http://economics.mit.edu/faculty/angrist/data1/data/aceang01"941 942 *------943 *-6.7.1 背背倍背 944 945 *-定的: 不参研公国美美美美主倍最(ADA)最最最图最最的最最。946 947 *-ADA 倍最简倍:https://www.ada.gov/ (ADA 地官)948 * ADA: 投由美美美连在1992年7月月详的一产倍最,很由连即经总基年年公个。949 * 2008年年即经总基年年年国美美主倍最年项最,引哪年项最在2009年1月1日公个。950 * ADA 的初的: 保保美美主在数在、解解图解解禁的高即中解解.951 * 中能的最最:952 * 西倍企最中能连就至部部美美主位;953 * i. 很最用本交用: 的隐为美美部最随年需需;954 * ii.解部(美美)地最的用本交用国;955 956 *-本参假本国时: 957 * [1] ADA 哪1990年7月写匿月倍;1992年7月项项公个;958 * [2] Males aged 21-39 from the 1988-1997 March CPS (调调年调, 每年3月)959 * [2] 哪实假本国时 1987-1996 年,刚好刚刚国 ADA 倍最哪哪执执的年调;960

A6_DID - Printed on 2018/5/22 16:57:07

Page 16

961 *-的倍: 多多 DID,每资哪基基哪基执执投否有在与与与与 962 963 *-Treat寻: disabled(美美主位); Control寻: 其其主地;964 965 use "$path\Acemoglu_2001_JPE_DID\ABA_JPE2001.dta", clear966 967 des2 //范范数数968 969 /*970 variable value label variable label971 ---------------------------------------------------------------------972 year year of work973 disabled disabled d.v., =1 if have work disability974 wkswork1 weeks worked last year975 wkwage weekly wage, $976 lnwkwage log of weekly wage977 white d.v., =1 if white978 black d.v., =1 if black979 working d.v., =1 if working980 posths d.v., =1 if post high school981 age_G age_G RECODE of age (age in years)982 edu_G edu_G RECODE of educrec (ipums education recode)983 race_G race_G 1=white, 2=black, 3=other984 region census region985 statefip state fips code986 age age in years987 race detailed race code988 educrec ipums education recode989 */990 991 *-描描公基的, 最变Treat寻图Control寻在Treat执执的基本之之992 *-------------------------------993 *-Table 1, Panel A, colum(1),(2) Men age 21-39994 *-------------------------------995 996 cap drop EvenYear997 gen EvenYear = mod(year,2)==0 //偶范年取1,否否取0, 列列时节省列时998 tab year Even999

1000 global v "age white posths working wkswork1 wkwage"1001 logout, save($Out\table1_disabled) excel replace: ///1002 tabstat $v if disabled==1&EvenYear==1, ///1003 format(%6.2f) s(mean N) by(year) nototal1004 1005 /*1006 year | age white posths working wkswork1 wkwage1007 -------+----------------------------------------------------------1008 1988 | 31.23 0.83 0.25 0.56 19.77 360.231009 | 863.00 863.00 863.00 863.00 863.00 451.001010 -------+----------------------------------------------------------1011 1990 | 31.13 0.81 0.24 0.51 18.75 361.381012 | 993.00 993.00 993.00 993.00 993.00 473.001013 -------+----------------------------------------------------------1014 1992 | 31.22 0.82 0.29 0.50 18.59 379.081015 | 1039.00 1039.00 1039.00 1039.00 1039.00 489.001016 -------+----------------------------------------------------------1017 1994 | 31.67 0.80 0.28 0.46 16.71 380.591018 | 864.00 864.00 864.00 864.00 864.00 384.001019 -------+----------------------------------------------------------1020 1996 | 31.69 0.81 0.28 0.47 17.01 384.731021 | 790.00 790.00 790.00 790.00 790.00 357.001022 ------------------------------------------------------------------1023 */1024

A6_DID - Printed on 2018/5/22 16:57:08

Page 17

1025 logout, save($Out\table1_nondisabled) excel replace: ///1026 tabstat $v if disabled==0&EvenYear==1, ///1027 format(%6.2f) s(mean N) by(year) nototal1028 1029 /*1030 year | age white posths working wkswork1 wkwage1031 -------+------------------------------------------------------------1032 1988 | 29.93 0.87 0.47 0.94 44.29 463.191033 | 18674.00 18674.00 18674.00 18674.00 18674.00 17212.001034 -------+------------------------------------------------------------1035 1990 | 30.01 0.87 0.46 0.96 45.15 488.771036 | 20094.00 20094.00 20094.00 20094.00 20094.00 18915.001037 -------+------------------------------------------------------------1038 1992 | 30.10 0.85 0.52 0.95 43.95 510.991039 | 19352.00 19352.00 19352.00 19352.00 19352.00 18001.001040 -------+------------------------------------------------------------1041 1994 | 30.33 0.83 0.53 0.94 44.54 547.181042 | 18181.00 18181.00 18181.00 18181.00 18181.00 16883.001043 -------+------------------------------------------------------------1044 1996 | 30.42 0.86 0.53 0.95 45.27 565.841045 | 15742.00 15742.00 15742.00 15742.00 15742.00 14623.001046 --------------------------------------------------------------------1047 */1048 1049 *-self-reading1050 *-----------哪为更美的回徐的项----------------------- begin -------1051 *1052 local qui "qui" //执执时即自回执,中可回徐详写结结1053 mat drop _all1054 local v "age white posths working wkswork1 wkwage"1055 global colnames ""1056 local j=11057 forvalues t = 1988(2)1996{1058 forvalues i = 1(-1)0{1059 qui tabstat `v' if disabled==`i'&year==`t', s(mean) c(s) save1060 mat a = r(StatTotal)1061 qui sum age if disabled==`i'&year==`t'1062 mat s`j' = (a' \ `r(N)')1063 mat A = (nullmat(A), s`j++')1064 }1065 global colnames "$colnames `t'_Dis `t'_Non"1066 *dis "$colnames"1067 }1068 mat colnames A = $colnames1069 mat rownames A = Age White Post-high-school Working Weeks_worked ///1070 Weekly_wage Observations1071 mat list A, format(%4.2f) noheader1072 *1073 *----------------------------------------------------- over --------1074 *1075 *-中外每 Excel 图图中1076 logout, save(Out\Table1_A_Men_21-39) excel replace fix(5): ///1077 matrix list A, format(%4.2f) noheader1078 *-Notes: 1079 * (1) option fix(5) 很哪保基中外的 Excel 图图时, 1080 * 第一执第一列的列图每可保第;1081 * (2) 执执完 logout 执执执,矩矩 A 最就自国就就国.1082 1083 /*1084 1988_Dis 1988_Non 1992_Dis 1992_Non 1996_Dis 1996_Non1085 Age 31.23 29.93 31.22 30.10 31.69 30.421086 White 0.83 0.87 0.82 0.85 0.81 0.861087 Post-high-~l 0.25 0.47 0.29 0.52 0.28 0.531088 Working 0.56 0.94 0.50 0.95 0.47 0.95

A6_DID - Printed on 2018/5/22 16:57:08

Page 18

1089 Weeks_worked 19.77 44.29 18.59 43.95 17.01 45.271090 Weekly_wage 360.23 463.19 379.08 510.99 384.73 565.841091 Observations 863.00 18674.00 1039.00 19352.00 790.00 15742.001092 */1093 1094 1095 *------1096 *-6.7.2 图图倍基:Common Tread1097 1098 *-------------------Figure 2-------------------begin------------------1099 *1100 *-定的: 省直国回徐 1992年(ADA) 执执美美主地每新最作时范的控变;1101 *-应多: 若Common trend寒与均的,1102 * 否 1992 年执执Treat寻图Control寻的每新最作时范基不个不变均组定;1103 preserve1104 collapse (mean) wkswork1, by(disabled year)1105 list, sepby(disabled)1106 xtset year disabled1107 list, sepby(year)1108 gen diff_weeksWork = -d.wkswork1 // mean(Nondisab)-mean(disab)1109 list, sepby(year)1110 #delimit ;1111 local text "Weeks worked last year by disability status of men";1112 twoway1113 (connected wkswork1 year if disabled==0)1114 (connected wkswork1 year if disabled==1)1115 (connected diff_weeksWork year, lp(longdash))1116 ,1117 scheme(s2mono) /* scheme(s2color) */1118 ytitle("Weeks Worked")1119 ylabel(10(5)50, angle(0))1120 xtitle("Year")1121 xlabel(1987(1)1996)1122 xline(1992, lp(dash) lc(red*1.5))1123 yline(25,lp(dash) lc(blue))1124 text(47 1994 "Non-disabled")1125 text(30.5 1994 "Difference")1126 text(14 1994 "disabled")1127 legend(label(1 "disabled men")1128 label(2 "nondisabled men")1129 label(3 "difference")1130 row(1))1131 note("FIG.2.- `text' aged 29-31");1132 #delitmit cr1133 graph export "Out\Figure2.wmf", replace //中外兼保有图图1134 restore1135 *-------------------Figure 2-------------------over-------------------1136 1137 *-Note: 当与与与与寒与就倍不不时,DID 的结结投每的的,1138 * 回时,即很 Synthetic Control Method 中可每每哪为中可的的的结结1139 1140 1141 *------1142 *-6.7.3 采采倍基:多多 DID1143 1144 *-基徐 参中 Table2. Panel A 1145 *-几个基隐的公公:1146 * (1) CPI 平就公公, 已很解已, 作低仅在作就 wkwage 控批的有群均时很每国平就;1147 * (2) 的的时的股基公公: 1148 * pp.950, All our estimates are weighted by CPS sample weights1149 * 自的我每的范范英就倍寻每股基控批,引中能投详写就倍完这这匿的参的主隐的干1150 1151 1152 *---------

A6_DID - Printed on 2018/5/22 16:57:08

Page 19

1153 *-Table 2: col(1) (5)1154 *---------1155 /* pp.9291156 Table 2 reports ordinary least squares (OLS) estimates of equation (6). 1157 就解匹控批: weeks worked (wkswork1) and log weekly earnings (lnwkwage).1158 控匿控批:1159 dummies for individual disability status, 1160 year dummies, 1161 two 10-year age groups, 1162 three schooling groups, 1163 three race groups, 1164 nine census region main effects, 1165 interaction terms for age#year, schooling#year, race#year, and region#year.1166 1167 [1] Coefficients of interest are a full set of year#disability interactions, 1168 with 1987 as the base period. 1169 [2] These year#disability interaction terms, that is, the a’s in equation (6), 1170 describe the change in relative employment of the disabled. 1171 [3] We think of 1993–96 as posttreatment years, whereas 1992 is a 1172 transition year during which the ADA was only partially in effect. 1173 [4] The pre-1992 years provide “pretreatment” specification tests, 1174 though they could also capture possible anticipation effects of the ADA.1175 */1176 1177 *-定定 disabilityX1988, disabilityX1989, ..., disabilityX19981178 dropvars disabX* yr*1179 forvalues t = 1988/1996{ // sample range: 1987-19961180 gen yr`t' = (year==`t')1181 }1182 forvalues t = 1988/1996{1183 gen disabX`t' = disabled*yr`t'1184 label var disabX`t' "Disability x `t'"1185 }1186 1187 *-最基本的 DID 倍基(的参原原引哪倍基,投连连连自是戒的)1188 dropvars *Post1189 gen Post = (year>1992) //ADA 投1992年7月项项公个的1190 gen disable_x_Post = disabled*Post1191 1192 *-DID采采1193 reg wkswork1 disabled Post disable_x_Post1194 est store DID_2period1195 1196 *-参仅多多1197 reg wkswork1 disabled yr1988-yr1996 disabX*1198 est store DID_Mperiod1199 *-如兼: 引个结结西倍这这 Common Trend 寒与,1200 * 干为 TreatX1988 图 TreatX1989 每即的的; 1201 * 参仅每 ADA 在1990年7月最已很写随月倍, 1992年7月项项公个引一背背,1202 * 交描结结图命有在[应多个个], 即西倍企最在1990-1992多时最已很西原1203 * 尽批至部部美美地最国。1204 1205 *-图列多多 DID 个结1206 *--------------------------------------------------begin---------------1207 #d ;1208 coefplot, keep(disabX*)1209 coeflabels(1210 disabX1988 = "-4"1211 disabX1989 = "-3"1212 disabX1990 = "-2"1213 disabX1991 = "-1"1214 disabX1992 = "1992"1215 disabX1993 = "+1"1216 disabX1994 = "+2"

A6_DID - Printed on 2018/5/22 16:57:08

Page 20

1217 disabX1995 = "+3"1218 disabX1996 = "+4")1219 vertical1220 yline(0, lp(dash) lc(black*0.4))1221 ytitle("Weeks") ylabel(,angle(0) format(%2.1f))1222 xtitle("Year passage relative to year of adoption of ADA")1223 addplot(line @b @at)1224 ciopts(recast(rcap))

1225 scheme(s2color);1226 #d cr1227 graph export "$out/Figure_Multi_DID_01.png", replace1228 *---------------------------------------------------over--------------- 1229 *-Notes:1230 * [1] addplot(line @b @at): 因戒一附上附投每的参范的的不连就附来1231 * [2] ciopts(recast(rcap)): 戒戒增信国时的交请增1232 1233 1234 *-扩国: 中可戒随哪多的控匿控批,控匿之个寻的个个之之基不.1235 1236 *-戒随控匿控批1237 global controls "i.age_G i.edu_G i.race_G i.region"1238 reg wkswork1 disabled yr1988-yr1996 disabX* $controls1239 estadd local Controls "Yes", replace1240 estadd local YrxControls "No" , replace1241 est store DID_Mp_control1242 1243 *--------------------------1244 *-的参 Table 2, Column (1): Y = weekes worked, Eq(6) in pp.9251245 1246 global controls "i.age_G i.edu_G i.race_G i.region" //控匿控批1247 1248 *=====================================================================1249 reg wkswork1 disabled i.year disabX* i.year##($controls) //cmd1250 * -------- -------- ------- ---------- ---------------------1251 * DID: outcome Treat Time Treat*Time Control Variables1252 *=====================================================================1253 estadd local Controls "Yes", replace1254 estadd local YrxControls "Yes", replace1255 est store Tab2_Col11256 *-Q: 自的戒随国哪哪控匿控批?1257 1258 *-----图列多多 DID 个结------------------------begin-------------------1259 #d ;1260 coefplot, keep(disabX*)1261 coeflabels(1262 disabX1988 = "-4"1263 disabX1989 = "-3"1264 disabX1990 = "-2"1265 disabX1991 = "-1"1266 disabX1992 = "1992"1267 disabX1993 = "+1"1268 disabX1994 = "+2"1269 disabX1995 = "+3"1270 disabX1996 = "+4")1271 vertical1272 yline(0, lp(dash) lc(black*0.4))

A6_DID - Printed on 2018/5/22 16:57:08

Page 21

1273 ytitle("Weeks") ylabel(,angle(0) format(%2.1f))1274 xtitle("Year passage relative to year of adoption of ADA")1275 addplot(line @b @at)1276 ciopts(recast(rcap))

1277 scheme(s2color);1278 #d cr1279 graph export "$out/Figure_Multi_DID_02.png", replace1280 *---------------------------------------------------over--------------- 1281 1282 *----------------1283 *-的参Column (5): Y = log(weekly earnings) 作为就解匹控批1284 reg lnwkwage disabled i.year disabX* $controls i.year#($controls)1285 estadd local Controls "Yes", replace1286 estadd local YrxControls "Yes", replace1287 est store Tab2_Col51288 *-----图列多多 DID 个结------------------------begin-------------------1289 #d ;1290 coefplot, keep(disabX*)1291 coeflabels(1292 disabX1988 = "-4"1293 disabX1989 = "-3"1294 disabX1990 = "-2"1295 disabX1991 = "-1"1296 disabX1992 = "1992"1297 disabX1993 = "+1"1298 disabX1994 = "+2"1299 disabX1995 = "+3"1300 disabX1996 = "+4")1301 vertical1302 yline(0, lp(dash) lc(black*0.4))1303 ytitle("Log(Weekly Wages)") ylabel(,angle(0) format(%2.1f))1304 xtitle("Year passage relative to year of adoption of ADA")1305 addplot(line @b @at)1306 ciopts(recast(rcap))

1307 scheme(s2color);1308 #d cr1309 graph export "$out/Figure_Multi_DID_03.png", replace1310 *---------------------------------------------------over--------------- 1311 1312 1313 *--------------1314 *-中外每 Excel 1315 1316 local s "using $Out\Table2.csv"1317 local m "DID_2period DID_Mperiod DID_Mp_control Tab2_Col1 Tab2_Col5"1318 local mt "Weeks ln(wage)"1319 local opt "nogaps b(%4.2f) star(* 0.1 ** 0.05 *** 0.01)"1320 esttab `m' `s', mtitle(Weeks Weeks Weeks Weeks ln(wage)) `opt' ///1321 scalars(Controls YrxControls N r2) sfmt(%10.1f %4.3f) ///1322 se keep(*Post disabX*) replace label1323 1324 *-结兼:1325 * [1] ADA 的哪哪的的的最国美美主位的每新最作时范(企最即企注部部美美主位)1326 * [2] ADA 的哪哪最美美主位的最最(Weekly Wage)中每的的最最

A6_DID - Printed on 2018/5/22 16:57:08

Page 22

1327 1328 /*1329 ------------------------------------------------------------------------------1330 (1) (2) (3) (4) (5) 1331 Weeks Weeks Weeks Weeks ln(wage) 1332 ------------------------------------------------------------------------------1333 Post 0.23*** 1334 (0.07) 1335 disable_x_Post -2.42*** 1336 (0.34) 1337 Disability x 1988 -0.74 -0.57 -0.69 0.05 1338 (0.73) (0.71) (0.72) (0.04) 1339 Disability x 1989 -0.76 -0.70 -0.54 -0.02 1340 (0.72) (0.70) (0.71) (0.04) 1341 Disability x 1990 -2.61*** -2.39*** -2.29*** 0.04 1342 (0.71) (0.69) (0.69) (0.04) 1343 Disability x 1991 -2.18*** -2.30*** -2.16*** 0.07* 1344 (0.70) (0.69) (0.69) (0.04) 1345 Disability x 1992 -1.57** -1.65** -1.39** -0.01 1346 (0.70) (0.68) (0.69) (0.04) 1347 Disability x 1993 -3.11*** -2.98*** -2.74*** -0.01 1348 (0.71) (0.69) (0.70) (0.04) 1349 Disability x 1994 -4.04*** -4.16*** -3.92*** -0.09** 1350 (0.73) (0.71) (0.72) (0.04) 1351 Disability x 1995 -3.56*** -3.82*** -3.70*** -0.00 1352 (0.76) (0.74) (0.75) (0.04) 1353 Disability x 1996 -4.47*** -4.70*** -4.47*** -0.14***1354 (0.75) (0.73) (0.74) (0.04) 1355 ------------------------------------------------------------------------------1356 Observations 195714 195714 195714 195714 177977 1357 Controls Yes Yes Yes 1358 YrxControls No Yes Yes 1359 r2 0.114 0.116 0.161 0.164 0.199 1360 ------------------------------------------------------------------------------1361 Standard errors in parentheses, * p<0.1, ** p<0.05, *** p<0.011362 */1363 1364 1365 1366 1367 *---------1368 *-Also See1369 1370 * 兼最的倍1371 help gmatch1372 help ccmatch1373 help optmatch21374 1375 *-Nonlinear “difference-in-differences”1376 view browse "http://ftp.iza.org/dp3478.pdf"1377 1378 *-其其执执1379 1380 help didq // DID under alternative parallel-q assumptions, SJ15-31381 shellout "$R\Mora_2015_Didq.pdf" //的参1382 doedit "didq_examples.do"1383 1384 1385 *-Semiparametric DID estimator1386 *-Abadie (2005)1387 * Abadie, A. 2005. 1388 * Semiparametric Difference-in-Differences Estimators. 1389 * Review of Economic Studies 72: 1-191390 shellout "$R\Abadie_2005_DIDq.pdf"

A6_DID - Printed on 2018/5/22 16:57:08

Page 23

1391 1392 help absdid1393 use "absdid.dta", clear1394 *-Estimate the union-wage premium1395 absdid dlwage, tvar(union97) xvar(age black hispanic married i.grade)1396