前沿: 多期或渐进或交叠DID, 如何进行平行趋势检验呢?
凡是搞计量经济的,都关注这个号了
稿件:econometrics666@126.com
所有计量经济圈方法论丛的code程序, 宏微观数据库和各种软件都放在社群里.欢迎到计量经济圈社群交流访问.
当然,这些程序都在Stata上运行过的,从中没有发现问题。
*代码放在社群里,群友可以下载下来,自己运行一下,很好理解。
clear all timer clear set seed 10 global T = 15 global I = 300 set obs `=$I*$T' gen i = int((_n-1)/$T )+1 gen t = mod((_n-1),$T )+1 tsset i t gen Ei = ceil(runiform()*7)+$T -6 if t==1 bys i (t): replace Ei = Ei[1] gen K = t-Ei gen D = K>=0 & Ei!=. gen tau = cond(D==1, (t-12.5), 0) gen eps = rnormal() gen Y = i + 3t + tauD + eps
*下图中i为个体,t为时期,Ei为个体i在哪个时期受到政策处理,K为个体i在政策处理前或政策处理后多少期,D为虚拟变量,等于1若个体i为政策处理的当前及后期。
1.用did_imputation做的估计:
面板数据
1) Estimate the single average treatment-on-the-treated (ATT) across all treated observations, assuming that FE can be imputed for all treated observations (which is rarely the case)
估计所有受到政策处理的个体的平均处理组上的处理效应 (ATT),假设固定效应可以归因于所有受到政策处理的个体(这种情况很少见)
. did_imputation Y i t Ei
2) Same but dropping the observations for which it cannot be imputed. (After running, investigate that the sample is what you think it is!)
. did_imputation Y i t Ei, autosample
3) Estimate the ATT by horizon //估计了动态效应
. did_imputation Y i t Ei, allhorizons autosample
4) Estimate the ATT at horizons 0..+6 only
. did_imputation Y i t Ei, horizons(0/6)
5) Estimate the ATT at horizons 0..+6 for the subset of units available for all of these horizons (such that the dynamics are not driven by compositional effects)
. did_imputation Y i t Ei, horizons(0/6) hbalance
6) Include time-varying controls: //加上了时变控制变量
. did_imputation Y i t Ei, controls(w_first w_other*)
7) Include state-by-year FE //加上了州-年份交互固定效应
. did_imputation Y county year Ei, fe(county state#year)
8) Drop unit FE
. did_imputation Y i t Ei, fe(t)
9) Additionally report pre-trend coefficients for leads 1,...,5. The estimates for post-treatment effects will NOT change. //加上了政策处理前的共同趋势
. did_imputation Y i t Ei, horizons(0/6) pretrends(5)
10) Estimate the difference between ATE at horizons +2 vs +1 [this can equivalently be done via lincom after estimating ATT by horizon]
. count if K==1
. gen wtr1 = (K==1)/r(N)
. count if K==2
. gen wtr2 = (K==2)/r(N)
. gen wtr_diff = wtr2-wtr1
. did_imputation Y i t Ei, wtr(wtr_diff) sum
11) Reduce estimation time by using loadweights when analyzing several outcomes with identical specifications on identical samples:
. did_imputation Y1 i t Ei, horizons(0/10) saveweights
. rename __* myweights* // optional
. did_imputation Y2 i t Ei, horizons(0/10) loadweights(myweights*)
21) 重复截面数据:
When in each period you have a different sample of individiuals i in the same groups (e.g. regions), replace individual FEs with group FEs and consider
clustering at the regional level:
. did_imputation Y i t Ei, fe(region t) cluster(region) ...
Note the main parameters still include i, and not region, as the unit identifier.
22)三重差分估计:
When observations are defined by i,g,t when, say, i are counties and g are age groups, specify a variable ig identifying the (i,g) pairs as the unit
identifier, add appropriate FEs, and choose your clustering level, e.g.:
. did_imputation Y ig t Eig, fe(ig i#t g#t) cluster(i) ...
Note that the event time Eig should be specific to the i,g pairs, not to the i. For instance, Eig is missing for a never-treated age group in a county where
other groups are treated at some point.
平行趋势及政策动态效应图:
3.用csdid做的估计:
4.用eventstudyinteract做的估计:
平行趋势及政策动态效应图:
5.用reghdfe做的估计:
2.5年,计量经济圈近1000篇不重类计量文章,
可直接在公众号菜单栏搜索任何计量相关问题,
Econometrics Circle
数据系列:空间矩阵 | 工企数据 | PM2.5 | 市场化指数 | CO2数据 | 夜间灯光 | 官员方言 | 微观数据 | 内部数据计量系列:匹配方法 | 内生性 | 工具变量 | DID | 面板数据 | 常用TOOL | 中介调节 | 时间序列 | RDD断点 | 合成控制 | 200篇合辑 | 因果识别 | 社会网络 | 空间DID数据处理:Stata | R | Python | 缺失值 | CHIP/ CHNS/CHARLS/CFPS/CGSS等 |干货系列:能源环境 | 效率研究 | 空间计量 | 国际经贸 | 计量软件 | 商科研究 | 机器学习 | SSCI | CSSCI | SSCI查询 | 名家经验计量经济圈组织了一个计量社群,有如下特征:热情互助最多、前沿趋势最多、社科资料最多、社科数据最多、科研牛人最多、海外名校最多。因此,建议积极进取和有强烈研习激情的中青年学者到社群交流探讨,始终坚信优秀是通过感染优秀而互相成就彼此的。