Stata:多期倍分法 (DID) 图示
Stata连享会 (知乎 | 简书 | 码云)
连享会 最新专题 直播
Source: mostly-harmless-replication - 05 Fixed Effects, DD and Panel Data
Note: 助教招聘信息请进入「课程主页」查看。
因果推断-内生性 专题 ⌚ 2020.11.12-15 主讲:王存同 (中央财经大学);司继春(上海对外经贸大学) 课程主页:https://gitee.com/arlionn/YG | 微信版
http://qr32.cn/BlTL43 (二维码自动识别)
空间计量 专题 ⌚ 2020.12.10-13 主讲:杨海生 (中山大学);范巧 (兰州大学) 课程主页:https://gitee.com/arlionn/SP | 微信版
https://gitee.com/arlionn/DSGE (二维码自动识别)
05 Fixed Effects, DD and Panel Data
5.2 Differences-in-differences
Figure 5-2-4 dofile
Completed in Stata.
Stata dofiles
clear all
set more off
eststo clear
capture version 14
/* Stata code for Figure 5.2.4 */
/* Download the data and unzip it */
shell curl -o outsourcingatwill_table7.zip "http://economics.mit.edu/~dautor/outsourcingatwill_table7.zip"
unzipfile outsourcingatwill_table7.zip
/*-------------*/
/* Import data */
/*-------------*/
use "table7/autor-jole-2003.dta", clear
/* Log total employment: from BLS employment & earnings */
gen lnemp = log(annemp)
/* Non-business-service sector employment from CBP */
gen nonemp = stateemp - svcemp
gen lnnon = log(nonemp)
gen svcfrac = svcemp / nonemp
/* Total business services employment from CBP */
gen bizemp = svcemp + peremp
gen lnbiz = log(bizemp)
/* Time trends */
gen t = year - 78 // Linear time trend
gen t2 = t^2 // Quadratic time trend
/* Restrict sample */
keep if inrange(year, 79, 95) & state != 98
/* Generate more aggregate demographics */
gen clp = clg + gtc
gen a1624 = m1619 + m2024 + f1619 + f2024
gen a2554 = m2554 + f2554
gen a55up = m5564 + m65up + f5564 + f65up
gen fem = f1619 + f2024 + f2554 + f5564 + f65up
gen white = rs_wm + rs_wf
gen black = rs_bm + rs_bf
gen other = rs_om + rs_of
gen married = marfem + marmale
/* Modify union variable */
replace unmem = . if inlist(year, 79, 81) // Don't interpolate 1979, 1981
replace unmem = unmem * 100 // Rescale into percentage
/* Diff-in-diff regression */
reg lnths lnemp admico_2 admico_1 admico0 admico1 admico2 admico3 mico4 admppa_2 admppa_1 ///
admppa0 admppa1 admppa2 admppa3 mppa4 admgfa_2 admgfa_1 admgfa0 admgfa1 admgfa2 admgfa3 ///
mgfa4 i.year i.state i.state#c.t, cluster(state)
coefplot, keep(admico_2 admico_1 admico0 admico1 admico2 admico3 mico4) ///
coeflabels(admico_2 = "2 yr prior" ///
admico_1 = "1 yr prior" ///
admico0 = "Yr of adopt" ///
admico1 = "1 yr after" ///
admico2 = "2 yr after" ///
admico3 = "3 yr after" ///
mico4 = "4+ yr after") ///
vertical ///
yline(0) ///
ytitle("Log points") ///
xtitle("Time passage relative to year of adoption of implied contract exception") ///
addplot(line @b @at) ///
ciopts(recast(rcap)) ///
rescale(100) ///
scheme(s1mono)
graph export "Figures/Figure 5-2-4.png", replace
/* End of script */
相关课程
连享会-直播课 上线了!
http://lianxh.duanshu.com
免费公开课:
- 直击面板数据模型 - 连玉君,时长:1 小时 40 分钟
- Stata 33 讲 - 连玉君, 每讲 15 分钟.
- 部分直播课 课程资料下载 (PPT,dofiles 等)
课程一览
支持回看,所有课程可以随时购买观看。
连享会 - 文本分析与爬虫 - 专题视频
主讲嘉宾:司继春 || 游万海
连享会 - 效率分析专题
已上线:可随时购买学习+全套课件,课程主页 已经放置板书和 FAQs
主讲嘉宾:连玉君 | 鲁晓东 | 张宁
课程主页,微信版 https://gitee.com/arlionn/TE
Note: 部分课程的资料,PPT 等可以前往 连享会-直播课 主页查看,下载。
关于我们
- Stata 连享会 由中山大学连玉君老师团队创办,定期分享实证分析经验。直播间 有很多视频课程,可以随时观看。
- 连享会-主页 和 知乎专栏,300+ 推文,实证分析不再抓狂。
- 公众号推文分类:计量专题 | 分类推文 | 资源工具。推文分成 内生性 | 空间计量 | 时序面板 | 结果输出 | 交乘调节 五类,主流方法介绍一目了然:DID, RDD, IV, GMM, FE, Probit 等。
连享会小程序:扫一扫,看推文,看视频……
扫码加入连享会微信群,提问交流更方便
编辑于 2020-09-27 21:43