美文网首页stata stata学习
Stata:多期倍分法 (DID) 图示

Stata:多期倍分法 (DID) 图示

作者: stata连享会 | 来源:发表于2018-04-09 08:31 被阅读635次

Stata连享会 (知乎 | 简书 | 码云)

Stata 现场培训报名中

Source: mostly-harmless-replication - 05 Fixed Effects, DD and Panel Data


05 Fixed Effects, DD and Panel Data

5.2 Differences-in-differences

Figure 5-2-4 dofile

Completed in Stata.

Figure 5-2-4 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 */

关于我们

联系我们

  • 欢迎赐稿: 欢迎将您的文章或笔记投稿至Stata连享会(公众号: StataChina),我们会保留您的署名;录用稿件达五篇以上,即可免费获得 Stata 现场培训 (初级或高级选其一) 资格。
  • 意见和资料: 欢迎您的宝贵意见,您也可以来信索取推文中提及的程序和数据。
  • 招募英才: 欢迎加入我们的团队,一起学习 Stata。合作编辑或撰写稿件五篇以上,即可免费获得 Stata 现场培训 (初级或高级选其一) 资格。
  • 联系邮件: StataChina@163.com

Stata 现场培训报名中

连玉君Stata现场班报名中

欢迎加入Stata连享会(公众号: StataChina)

相关文章

网友评论

    本文标题:Stata:多期倍分法 (DID) 图示

    本文链接:https://www.haomeiwen.com/subject/mddbhftx.html