查看原文
其他

Stata:异质性稳健DID估计量方法汇总

连享会 连享会 2023-10-24

👇 连享会 · 推文导航 | www.lianxh.cn

连享会 · 2022空间计量专题

   

作者:梁淑珍 (华侨大学)
邮箱:13514084150@163.com


温馨提示: 文中链接在微信中无法生效。请点击底部「阅读原文」。或直接长按/扫描如下二维码,直达原文:

编者按:本文主要摘译自下文,特此致谢!
Source:De Chaisemartin C, D'Haultfoeuille X. Two-way fixed effects and differences-in-differences with heterogeneous treatment effects: A survey[R]. National Bureau of Economic Research, 2022. -PDF-


目录

  • 1. 引言

  • 2. 模拟数据的生成

  • 3. 异质性稳健 DID 估计量

    • 3.1 did_imputation

    • 3.2 did_multiplegt

    • 3.3 csdid

    • 3.4 eventstudyinteract

    • 3.5 did2s

    • 3.6 stackedev

    • 3.7 TWFE OLS

    • 3.8 xtevent

    • 3.9 eventdd

  • 4. 相关推文



连享会推文「DID 最新进展:异质性处理条件下的双向固定效应 DID 估计量 (TWFEDD)」从理论角度详细介绍了异质性处理情况下 TWFE 估计量存在的问题,并对学者提出的诊断及修正方法进行了回顾与梳理。本文侧重于介绍论文中提及的部分异质性稳健 DID 估计量的 Stata 命令。

1. 引言

双向固定效应回归 (Two-way Fixed Effects,TWFE) 是识别处理效应最常用的估计方法之一,但是要想得到无偏的平均处理效应需要满足以下假设:

  • 平行趋势假定;
  • 处理效应无组群和不同时点的异质性。

然而在现实情况下,假设 (2) 很难得到满足。因此 TWFE 估计量得到的估计系数很可能存在偏误,甚至产生错误比较和负权重等问题。很多学者提出了 TWFE 的替代估计方法,本文将展示这些异质性稳健 DID 估计量的 Stata 操作。

2. 模拟数据的生成

本文使用的基础数据结构为 300 个体 × 15 时期 = 4500 个观察值的平衡面板数据。后文中的估计量均使用这份模拟数据。

. clear all
. timer clear

. * 设定随机数种子, 设置 4500 个样本观测值
. set seed 10
. global T = 15
. global I = 300
. set obs `=$I*$T'

. * 生成 id 与时间
. gen i = int((_n-1)/$T )+1
. gen t = mod((_n-1),$T )+1
. tsset i t

. * 随机生成每个 i d首次接受处理的时间标志, Ei 的取值在 10 和 16 之间
. gen Ei = ceil(runiform()*7)+$T -6 if t==1
. bys i (t): replace Ei = Ei[1]

. * 生成处理变量, K 为相对处理时间, D 为处理时间哑变量
. gen K = t-Ei
. gen D = K>=0 & Ei!=.

. * 生成时间上的异质性处理效应
. gen tau = cond(D==1, (t-12.5), 0)

. * 生成误差项
. gen eps = rnormal()

. * 生成结果变量Y
. gen Y = i + 3*t + tau*D + eps

3. 异质性稳健 DID 估计量

3.1 did_imputation

Borusyak 等 (2021) 提供了一种基于插补的反事实方法解决 TWFE 的估计偏误问题。基于 TWFE,通过估计组群固定效应、时间固定效应和处理组-控制组固定效应,可以得到更准确的估计量,具体可参考连享会推文「Stata:事件研究法的稳健有效估计量-did_imputation」。

. did_imputation Y i t Ei, allhorizons pretrends(5)

Number of obs = 4,500
------------------------------------------------------------------------------
Y | Coefficient Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
tau0 | 0.085 0.080 1.07 0.284 -0.071 0.242
tau1 | 0.670 0.084 7.99 0.000 0.505 0.834
tau2 | 1.084 0.101 10.71 0.000 0.885 1.282
tau3 | 1.605 0.133 12.04 0.000 1.343 1.866
tau4 | 1.919 0.153 12.53 0.000 1.619 2.219
tau5 | 2.651 0.243 10.90 0.000 2.175 3.128
pre1 | -0.089 0.124 -0.72 0.474 -0.333 0.155
pre2 | -0.022 0.106 -0.21 0.833 -0.231 0.186
pre3 | -0.067 0.100 -0.67 0.506 -0.264 0.130
pre4 | -0.014 0.088 -0.16 0.869 -0.187 0.158
pre5 | -0.033 0.071 -0.47 0.639 -0.174 0.107
------------------------------------------------------------------------------

可以看出,pre1-pre5 值均不显著,该数据集满足平行趋势假设,tau1-tau4 值显著,表现为异质性处理效应。进一步使用 event_plot 命令,将不同时期的处理效应系数绘制出来。

. event_plot, default_look graph_opt(xtitle("Periods since the event") ytitle("Average causal effect") ///
> title("Borusyak et al. (2021) imputaion estimator") xlabel(-5(1)5) name(BJS, replace)) together

3.2 did_multiplegt

De Chaisemartin 和 D‘Haultfoeuille (2020) 提出通过加权计算两种处理效应的值得到平均处理效应的无偏估计,这两种处理效应为:

  • 期未受处理而 期受处理的组与两期都未处理的组的平均处理效应;
  • 期受处理而 期未受处理的组与两期都受处理的组的平均处理效应。

该方法的前提条件是处理效应不具有动态性 (即处理效应与过去的处理状态无关),具体可参考连享会推文「DIDM:多期多个体倍分法-did_multiplegt」。

. did_multiplegt Y i t D, robust_dynamic dynamic(5) placebo(5) longdiff_placebo breps(100) cluster(i)

| Estimate SE LB CI UB CI N Switchers
-------------+------------------------------------------------------------------
Effect_0 | .1408578 .1581723 -.16916 .4508756 1211 250
Effect_1 | .7141733 .1371814 .4452979 .9830488 899 205
Effect_2 | 1.132017 .1400374 .8575438 1.40649 628 164
Effect_3 | 1.565301 .1709356 1.230268 1.900335 398 117
Effect_4 | 1.899413 .2036894 1.500182 2.298644 215 70
Effect_5 | 2.773816 .3108357 2.164578 3.383054 83 33
Placebo_1 | .0482671 .1020707 -.1517915 .2483257 1211 250
Placebo_2 | .0460625 .1096916 -.1689331 .261058 899 205
Placebo_3 | .0305153 .1082104 -.1815771 .2426078 628 164
Placebo_4 | -.0692496 .1461691 -.355741 .2172418 398 117
Placebo_5 | .0299686 .1821709 -.3270864 .3870236 215 70

绘制各期处理效应图:

. event_plot e(estimates)#e(variances), default_look graph_opt(xtitle("Periods since the event") ///
> ytitle("Average causal effect") title("de Chaisemartin and D'Haultfoeuille (2020)") ///
> xlabel(-5(1)5) name(dCdH, replace)) stub_lag(Effect_#) stub_lead(Placebo_#) together

3.3 csdid

Callaway 和 SantAnna (2021) 将 期以前从未受处理的组作为控制组进行估计,代码如下:

. * 生成日期变量,从未受处理的组取值为 0
. gen gvar = cond(Ei>15, 0, Ei)
. csdid Y, ivar(i) time(t) gvar(gvar) agg(event)

Difference-in-difference with Multiple Time Periods
Number of obs = 4,500
Outcome model : weighted least squares
Treatment model: inverse probability tilting
------------------------------------------------------------------------------
| Coefficient Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
T-13 | 0.219 0.321 0.68 0.496 -0.411 0.849
T-12 | 0.127 0.185 0.69 0.492 -0.236 0.491
T-11 | -0.025 0.144 -0.17 0.861 -0.307 0.257
T-10 | -0.188 0.128 -1.47 0.140 -0.438 0.062
T-9 | 0.141 0.110 1.28 0.199 -0.074 0.357
T-8 | 0.019 0.102 0.18 0.855 -0.182 0.219
T-7 | 0.068 0.101 0.67 0.501 -0.129 0.265
T-6 | 0.038 0.094 0.40 0.688 -0.146 0.221
T-5 | -0.048 0.092 -0.52 0.606 -0.228 0.133
T-4 | -0.020 0.096 -0.21 0.834 -0.209 0.168
T-3 | -0.081 0.092 -0.88 0.378 -0.262 0.099
T-2 | 0.037 0.104 0.35 0.723 -0.167 0.241
T-1 | -0.102 0.097 -1.05 0.293 -0.291 0.088
T+0 | 0.106 0.147 0.72 0.474 -0.183 0.395
T+1 | 0.632 0.146 4.33 0.000 0.346 0.918
T+2 | 0.995 0.160 6.21 0.000 0.681 1.308
T+3 | 1.465 0.184 7.98 0.000 1.105 1.825
T+4 | 1.821 0.218 8.34 0.000 1.393 2.248
T+5 | 2.774 0.289 9.60 0.000 2.208 3.340
------------------------------------------------------------------------------
Control: Never Treated
See Callaway and Sant'Anna (2021) for details
. event_plot e(b)#e(V), default_look graph_opt(xtitle("Periods since the event") ///
> ytitle("Average causal effect") xlabel(-14(1)5) title("Callaway and Sant'Anna (2020)") ///
> name(CS, replace)) stub_lag(T+#) stub_lead(T-#) together

3.4 eventstudyinteract

Sun 和 Abraham (2020) 认为还能够使用后处理组作为控制组,允许使用简单的线性回归进行估计,代码如下:

. sum Ei
. * 生成从未受处理组的虚拟变量
. gen lastcohort = Ei==r(max)
. * 生成各期处理组的虚拟变量
. forvalues l = 0/5 {
2. gen L`l'event = K==`l'
3. }
. forvalues l = 1/14 {
2. gen F`l'event = K==-`l'
3. }
. drop F1event
. eventstudyinteract Y L*event F*event, vce(cluster i) absorb(i t) cohort(Ei) control_cohort(lastcohort)

IW estimates for dynamic effects Number of obs = 4,500
Absorbing 2 HDFE groups F(84, 299) = 9.76
Prob > F = 0.0000
R-squared = 0.9999
Adj R-squared = 0.9999
Root MSE = 1.0191
(Std. err. adjusted for 300 clusters in i)
------------------------------------------------------------------------------
| Robust
Y | Coefficient std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
L0event | 0.106 0.148 0.71 0.477 -0.186 0.397
L1event | 0.632 0.147 4.30 0.000 0.343 0.921
L2event | 0.995 0.161 6.16 0.000 0.677 1.312
L3event | 1.465 0.186 7.89 0.000 1.100 1.831
L4event | 1.821 0.221 8.24 0.000 1.386 2.255
L5event | 2.774 0.293 9.48 0.000 2.198 3.350
F2event | 0.102 0.098 1.04 0.300 -0.091 0.295
F3event | 0.065 0.098 0.66 0.511 -0.129 0.258
F4event | 0.146 0.110 1.33 0.183 -0.069 0.362
F5event | 0.166 0.116 1.44 0.152 -0.062 0.394
F6event | 0.214 0.126 1.70 0.091 -0.034 0.462
F7event | 0.176 0.130 1.35 0.178 -0.080 0.433
F8event | 0.109 0.132 0.83 0.410 -0.150 0.367
F9event | 0.090 0.130 0.69 0.492 -0.167 0.346
F10event | -0.055 0.138 -0.40 0.693 -0.327 0.218
F11event | 0.165 0.140 1.18 0.239 -0.110 0.441
F12event | 0.247 0.161 1.53 0.128 -0.071 0.564
F13event | 0.082 0.209 0.39 0.697 -0.330 0.493
F14event | -0.072 0.299 -0.24 0.810 -0.661 0.516
------------------------------------------------------------------------------

如果出现报错 command avar is unrecognized,则输入 ssc install avar,安装后再次运行命令。

. event_plot e(b_iw)#e(V_iw), default_look graph_opt(xtitle("Periods since the event") ///
> ytitle("Average causal effect") xlabel(-14(1)5) title("Sun and Abraham (2020)") ///
> name(SA, replace)) stub_lag(L#event) stub_lead(F#event) together

3.5 did2s

Gardner (2021) 提出的两阶段双重差分的基本原理:在第一阶段识别组群处理效应和时期处理效应的异质性,在第二阶段时再将异质性处理效应剔除,具体可参考连享会推文「Stata 倍分法新趋势:did2s-两阶段双重差分模型」。

. did2s Y, first_stage(i.i i.t) second_stage(F*event L*event) treatment(D) cluster(i)
(Std. err. adjusted for clustering on i)
------------------------------------------------------------------------------
| Coefficient Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
F2event | 0.026 0.050 0.51 0.609 -0.073 0.124
F3event | -0.026 0.052 -0.49 0.622 -0.129 0.077
F4event | 0.017 0.054 0.32 0.748 -0.088 0.122
F5event | -0.009 0.050 -0.18 0.853 -0.108 0.089
F6event | 0.021 0.053 0.39 0.695 -0.084 0.126
F7event | 0.031 0.053 0.60 0.550 -0.072 0.134
F8event | -0.015 0.056 -0.26 0.795 -0.124 0.095
F9event | 0.017 0.054 0.31 0.756 -0.089 0.122
F10event | -0.090 0.062 -1.46 0.143 -0.211 0.031
F11event | 0.048 0.061 0.79 0.432 -0.071 0.167
F12event | 0.072 0.069 1.04 0.299 -0.064 0.207
F13event | -0.004 0.080 -0.05 0.957 -0.162 0.153
F14event | -0.121 0.093 -1.30 0.194 -0.304 0.062
L0event | 0.085 0.136 0.63 0.531 -0.182 0.353
L1event | 0.670 0.128 5.25 0.000 0.420 0.919
L2event | 1.084 0.130 8.37 0.000 0.830 1.338
L3event | 1.605 0.153 10.48 0.000 1.305 1.905
L4event | 1.919 0.168 11.41 0.000 1.589 2.248
L5event | 2.651 0.243 10.90 0.000 2.175 3.128
------------------------------------------------------------------------------
. event_plot, default_look stub_lag(L#event) stub_lead(F#event) together ///
> graph_opt(xtitle("Periods since the event") ytitle("Average causal effect") ///
> xlabel(-14(1)5) title("Gardner (2021)") name(DID2S, replace))

3.6 stackedev

与计算加权 ATT 的方法相比,Cengiz 等 (2019) 认为堆叠 (Stacking) 也是解决 TWFE 估计偏误的替代方法,基本思路是将数据集重建为相对事件时间的平衡面板,然后控制组群效应和时间固定效应,以得到处理效应的加权平均值。

. gen treat_year=.
. replace treat_year=Ei if Ei!=16
. * 生成从未受处理的虚拟变量
. gen no_treat= (Ei==16)
. cap drop F*event L*event
. sum Ei
. forvalues l = 0/5 {
2. gen L`l'event = K==`l'
3. replace L`l'event = 0 if no_treat==1
4. }
. forvalues l = 1/14 {
2. gen F`l'event = K==-`l'
3. replace F`l'event = 0 if no_treat==1
4. }
. drop F1event

. * 运行 stackedev 命令
. preserve
. stackedev Y F*event L*event, cohort(treat_year) time(t) never_treat(no_treat) unit_fe(i) clust_unit(i)
. restore

HDFE Linear regression Number of obs = 8,250
Absorbing 2 HDFE groups F( 19, 508) = 27.30
Statistics robust to heteroskedasticity Prob > F = 0.0000
R-squared = 0.9999
Adj R-squared = 0.9998
Within R-sq. = 0.0658
Number of clusters (unit_stack) = 509 Root MSE = 1.0677
(Std. err. adjusted for 509 clusters in unit_stack)
------------------------------------------------------------------------------
| Robust
Y | Coefficient std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
F2event | 0.108 0.122 0.89 0.373 -0.131 0.347
F3event | 0.063 0.121 0.52 0.603 -0.174 0.300
F4event | 0.141 0.123 1.15 0.250 -0.100 0.383
F5event | 0.163 0.120 1.36 0.175 -0.073 0.399
F6event | 0.210 0.127 1.66 0.097 -0.038 0.459
F7event | 0.170 0.125 1.36 0.174 -0.075 0.416
F8event | 0.103 0.125 0.83 0.408 -0.142 0.349
F9event | 0.093 0.122 0.76 0.447 -0.147 0.332
F10event | -0.158 0.130 -1.22 0.225 -0.414 0.098
F11event | -0.068 0.136 -0.50 0.618 -0.334 0.199
F12event | -0.120 0.147 -0.82 0.411 -0.408 0.167
F13event | -0.316 0.183 -1.73 0.084 -0.675 0.042
F14event | -0.456 0.234 -1.95 0.051 -0.915 0.003
L0event | 0.046 0.145 0.32 0.751 -0.239 0.332
L1event | 0.658 0.149 4.43 0.000 0.366 0.950
L2event | 1.132 0.148 7.65 0.000 0.841 1.423
L3event | 1.810 0.167 10.81 0.000 1.481 2.139
L4event | 2.347 0.185 12.72 0.000 1.985 2.710
L5event | 3.370 0.251 13.42 0.000 2.877 3.863
_cons | 168.183 0.038 4390.68 0.000 168.108 168.259
------------------------------------------------------------------------------
. event_plot e(b)#e(V), default_look graph_opt(xtitle("Periods since the event") ///
> ytitle("Average causal effect") xlabel(-14(1)5) title("Cengiz et al. (2019)") ///
> name(CDLZ, replace)) stub_lag(L#event) stub_lead(F#event) together

3.7 TWFE OLS

多维固定效应 OLS 代码:

. reghdfe Y F*event L*event, absorb(i t) vce(cluster i)

HDFE Linear regression Number of obs = 4,500
Absorbing 2 HDFE groups F( 19, 299) = 9.24
Statistics robust to heteroskedasticity Prob > F = 0.0000
R-squared = 0.9999
Adj R-squared = 0.9998
Within R-sq. = 0.0402
Number of clusters (i) = 300 Root MSE = 1.0769
(Std. err. adjusted for 300 clusters in i)
------------------------------------------------------------------------------
| Robust
Y | Coefficient std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
F2event | 0.152 0.094 1.61 0.108 -0.034 0.337
F3event | 0.077 0.096 0.81 0.418 -0.111 0.265
F4event | 0.042 0.104 0.40 0.687 -0.162 0.246
F5event | -0.056 0.102 -0.55 0.580 -0.257 0.144
F6event | -0.084 0.110 -0.76 0.446 -0.300 0.132
F7event | -0.145 0.112 -1.29 0.197 -0.366 0.076
F8event | -0.244 0.120 -2.04 0.043 -0.480 -0.008
F9event | -0.322 0.124 -2.60 0.010 -0.565 -0.078
F10event | -0.577 0.137 -4.22 0.000 -0.846 -0.308
F11event | -0.495 0.140 -3.53 0.000 -0.770 -0.219
F12event | -0.553 0.161 -3.44 0.001 -0.870 -0.236
F13event | -0.867 0.184 -4.72 0.000 -1.229 -0.505
F14event | -1.046 0.226 -4.62 0.000 -1.492 -0.601
L0event | -0.168 0.126 -1.33 0.183 -0.416 0.080
L1event | 0.358 0.113 3.17 0.002 0.136 0.581
L2event | 0.610 0.118 5.18 0.000 0.379 0.842
L3event | 0.978 0.142 6.87 0.000 0.698 1.258
L4event | 1.159 0.160 7.25 0.000 0.844 1.473
L5event | 1.634 0.221 7.39 0.000 1.199 2.070
_cons | 174.690 0.064 2719.06 0.000 174.564 174.817
------------------------------------------------------------------------------
. event_plot, default_look stub_lag(L#event) stub_lead(F#event) together ///
> graph_opt(xtitle("Days since the event") ytitle("OLS coefficients") ///
> xlabel(-14(1)5) title("OLS") name(OLS, replace))

3.8 xtevent

Freyaldenhoven 等 (2019) 提出处理面板事件研究的估计方法,代码如下:

. xtevent Y, policyvar(D) panelvar(i) timevar(t) window(4) plot

Linear regression, absorbing indicators Number of obs = 1,800
Absorbed variable: i No. of categories = 300
F(11, 1489) = 3952.82
Prob > F = 0.0000
R-squared = 0.9999
Adj R-squared = 0.9999
Root MSE = 1.0234
------------------------------------------------------------------------------
Y | Coefficient Std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
_k_eq_m5 | -0.074 0.170 -0.44 0.663 -0.408 0.260
_k_eq_m4 | -0.088 0.139 -0.63 0.526 -0.361 0.185
_k_eq_m3 | -0.049 0.133 -0.37 0.713 -0.309 0.212
_k_eq_m2 | -0.014 0.129 -0.11 0.911 -0.268 0.239
_k_eq_p0 | -2.034 0.162 -12.53 0.000 -2.353 -1.716
_k_eq_p1 | -1.458 0.227 -6.43 0.000 -1.903 -1.013
_k_eq_p2 | 0.000 (omitted)
_k_eq_p3 | 0.000 (omitted)
_k_eq_p4 | 0.000 (omitted)
_k_eq_p5 | 0.000 (omitted)
t |
7 | 3.025 0.085 35.74 0.000 2.859 3.191
8 | 5.874 0.089 66.25 0.000 5.700 6.048
9 | 8.992 0.097 92.30 0.000 8.801 9.183
10 | 12.006 0.111 107.77 0.000 11.787 12.225
11 | 15.039 0.133 112.95 0.000 14.778 15.300
|
_cons | 168.563 0.175 965.67 0.000 168.220 168.905
------------------------------------------------------------------------------
F test of absorbed indicators: F(299, 1489) = 4.3e+04 Prob > F = 0.000
Warning: Some event-time dummies were omitted in the regression. These coefficients
will be shown as zero in the plot. Check the window and the instruments, if any.

3.9 eventdd

eventdd 是 Damian Clarke 和 Kathya Tapia (2020) 共同开发的事件研究法代码,具体可参考连享会推文「Stata:面板事件研究法-eventdd」。

. eventdd Y i.t,timevar(K) method(fe, cluster(i)) balanced graph_op(ytitle("Y"))
note: lead15 omitted because of collinearity

Fixed-effects (within) regression Number of obs = 4500
Group variable: i Number of groups = 300
R-sq: Within = 0.9939 Obs per group: min = 15
Between = 0.0028 avg = 15.0
Overall = 0.0228 max = 15
F(33,299) = 19538.43
corr(u_i, Xb) = -0.0006 Prob > F = 0.0000
(Std. err. adjusted for 300 clusters in i)
------------------------------------------------------------------------------
| Robust
Y | Coefficient std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
t |
2 | 2.926 0.091 31.99 0.000 2.746 3.106
3 | 5.867 0.086 67.84 0.000 5.697 6.037
4 | 8.771 0.084 104.41 0.000 8.606 8.936
5 | 11.772 0.093 126.73 0.000 11.589 11.955
6 | 14.734 0.103 143.72 0.000 14.533 14.936
7 | 17.689 0.112 157.52 0.000 17.468 17.910
8 | 20.509 0.113 181.12 0.000 20.286 20.731
9 | 23.640 0.116 203.61 0.000 23.411 23.868
10 | 26.458 0.140 189.33 0.000 26.183 26.733
11 | 29.295 0.135 216.99 0.000 29.029 29.560
12 | 32.439 0.137 236.15 0.000 32.169 32.709
13 | 35.815 0.154 232.85 0.000 35.512 36.117
14 | 39.351 0.168 234.66 0.000 39.021 39.681
15 | 43.222 0.197 219.04 0.000 42.833 43.610
|
lead15 | 0.000 (omitted)
lead14 | -0.236 0.179 -1.32 0.188 -0.588 0.116
lead13 | -0.126 0.152 -0.83 0.406 -0.425 0.172
lead12 | -0.034 0.149 -0.23 0.819 -0.326 0.258
lead11 | -0.018 0.132 -0.14 0.889 -0.279 0.242
lead10 | -0.095 0.126 -0.76 0.450 -0.343 0.152
lead9 | 0.106 0.119 0.89 0.374 -0.128 0.340
lead8 | 0.127 0.110 1.15 0.251 -0.090 0.344
lead7 | 0.220 0.100 2.20 0.028 0.023 0.417
lead6 | 0.295 0.101 2.93 0.004 0.097 0.493
lead5 | 0.350 0.091 3.84 0.000 0.170 0.529
lead4 | 0.423 0.091 4.66 0.000 0.245 0.602
lead3 | 0.371 0.086 4.33 0.000 0.202 0.539
lead2 | 0.321 0.084 3.83 0.000 0.156 0.486
lag0 | 0.078 0.130 0.60 0.550 -0.178 0.333
lag1 | 0.579 0.122 4.75 0.000 0.339 0.819
lag2 | 0.808 0.132 6.12 0.000 0.548 1.068
lag3 | 1.153 0.162 7.14 0.000 0.835 1.471
lag4 | 1.313 0.183 7.17 0.000 0.953 1.674
lag5 | 1.761 0.246 7.17 0.000 1.277 2.244
_cons | 153.565 0.117 1314.12 0.000 153.335 153.795
-------------+----------------------------------------------------------------
sigma_u | 86.770012
sigma_e | 1.0779864
rho | .99984568 (fraction of variance due to u_i)
------------------------------------------------------------------------------

此外,还有 drdidflexpaneldidstaggeredjwdid 等命令。在实际应用过程中,为了解决 TWFE 估计偏误的问题,不妨将上述异质性稳健估计量都使用一遍,若能够通过大部分的估计量检验,那么结果就是可靠的。

4. 相关推文

Note:产生如下推文列表的 Stata 命令为:
lianxh did, m
安装最新版 lianxh 命令:
ssc install lianxh, replace

  • 专题:倍分法DID
    • DID偏误问题:多时期DID的双重稳健估计量(下)-csdid
    • DID偏误问题:两时期DID的双重稳健估计量(上)-drdid
    • Stata+R:合成DID原理及实现-sdid
    • DID的陷阱和注意事项
    • Stata:事件研究法的稳健有效估计量-did_imputation
    • DID最新进展:异质性处理条件下的双向固定效应DID估计量 (TWFEDD)
    • Stata倍分法新趋势:did2s-两阶段双重差分模型
    • DID陷阱解析-L111
    • DIDM:多期多个体倍分法-did_multiplegt
    • 面板PSM+DID如何做匹配?
    • 倍分法:DID是否需要随机分组?
    • Fuzzy DID:模糊倍分法
    • DID:仅有几个实验组样本的倍分法 (双重差分)
    • 考虑溢出效应的倍分法:spillover-robust DID
    • tfdiff:多期DID的估计及图示
    • 倍分法DID:一组参考文献
    • Stata:双重差分的固定效应模型-(DID)
    • 倍分法(DID)的标准误:不能忽略空间相关性
    • 多期DID之安慰剂检验、平行趋势检验
    • DID边际分析:让政策评价结果更加丰满
    • Big Bad Banks:多期 DID 经典论文介绍
    • 多期DID:平行趋势检验图示
    • Stata:多期倍分法 (DID) 详解及其图示

课程推荐:因果推断实用计量方法
主讲老师:丘嘉平教授
🍓 课程主页https://gitee.com/lianxh/YGqjp

New! Stata 搜索神器:lianxhsongbl  GIF 动图介绍
搜: 推文、数据分享、期刊论文、重现代码 ……
👉 安装:
. ssc install lianxh
. ssc install songbl
👉  使用:
. lianxh DID 倍分法
. songbl all

🍏 关于我们

  • 连享会 ( www.lianxh.cn,推文列表) 由中山大学连玉君老师团队创办,定期分享实证分析经验。
  • 直通车: 👉【百度一下: 连享会】即可直达连享会主页。亦可进一步添加 「知乎」,「b 站」,「面板数据」,「公开课」 等关键词细化搜索。


您可能也对以下帖子感兴趣

文章有问题?点此查看未经处理的缓存