雙重差分法( 在此借鑒參考 Using Stata to estimate difference-in-differences models with fixed effects 簡要回顧雙重差分模型的設(shè)定形式:
模型(1)為雙重差分模型的基本設(shè)定,。其中,,
模型(2)是加入個體固定效應(yīng) ( 下面,我們通過一份模擬數(shù)據(jù)來對比分析不同估計方法的效果和偏誤,。 1.生成數(shù)據(jù)
set obs 400gen firm=_n
expand 24bysort firm: gen t=_n
gen d=(t>=14)label var d '=1 if post-treatment'
gen r=rnormal()qui sum r, dbysort firm: gen i=(r>=r(p50)) if _n==1bysort firm: replace i=i[_n-1] if i==. & _n!=1drop rlabel var i '=1 if treated group, =0 if untreated group'
gen e = rnormal()label var e 'normal random variable' 2.驗證模型
gen y = .3 + .19*i + 1.67*d + .56*i*d + e 2.1 混合回歸
reg y i d Source | SS df MS Number of obs = 9600-------------+------------------------------ F( 2, 9597) = 4406.07 Model | 9073.16808 2 4536.58404 Prob > F = 0.0000 Residual | 9881.26843 9597 1.02962055 R-squared = 0.4787-------------+------------------------------ Adj R-squared = 0.4786 Total | 18954.4365 9599 1.97462616 Root MSE = 1.0147------------------------------------------------------------------------------ y | Coef. Std. Err. t P>|t| [95% Conf. Interval]-------------+---------------------------------------------------------------- i | .4349154 .0208277 20.88 0.000 .3940888 .475742 d | 1.902249 .0207848 91.52 0.000 1.861506 1.942991 _cons | .192176 .0168782 11.39 0.000 .1590912 .2252609------------------------------------------------------------------------------
reg y i d, robust ------------------------------------------------------------------------------ | Robust y | Coef. Std. Err. t P>|t| [95% Conf. Interval]-------------+---------------------------------------------------------------- i | .4349154 .0208446 20.86 0.000 .3940555 .4757753 d | 1.902249 .0207964 91.47 0.000 1.861483 1.943014 _cons | .192176 .0168581 11.40 0.000 .1591307 .2252214------------------------------------------------------------------------------ reg y i d, cluster(firm) ------------------------------------------------------------------------------ | Robust y | Coef. Std. Err. t P>|t| [95% Conf. Interval]-----------+---------------------------------------------------------------- i | .4349154 .0211226 20.59 0.000 .3933899 .4764408 d | 1.902249 .0239605 79.39 0.000 1.855144 1.949353 _cons | .192176 .0181038 10.62 0.000 .1565853 .2277668------------------------------------------------------------------------------
reg y i d i.i##i.deststo pooled ------------------------------------------------------------------------------ y | Coef. Std. Err. t P>|t| [95% Conf. Interval]-------------+---------------------------------------------------------------- i | .174383 .0280267 6.22 0.000 .1194448 .2293213 d | 1.647874 .0276935 59.50 0.000 1.593589 1.702159 1.i | 0 (omitted) 1.d | 0 (omitted) | i#d | 1 1 | .5684342 .0413982 13.73 0.000 .4872851 .6495834 | _cons | .3087643 .0187486 16.47 0.000 .2720131 .3455154------------------------------------------------------------------------------
2.2 areg回歸areg y i d i.i##i.d, absorb(firm)eststo areg ------------------------------------------------------------------------------ y | Coef. Std. Err. t P>|t| [95% Conf. Interval]-------------+---------------------------------------------------------------- i | 0 (omitted) d | 1.647874 .0276586 59.58 0.000 1.593657 1.702091 1.i | 0 (omitted) 1.d | 0 (omitted) | i#d | 1 1 | .5684342 .041346 13.75 0.000 .4873869 .6494815 | _cons | .3868007 .0139183 27.79 0.000 .3595177 .4140837-------------+---------------------------------------------------------------- firm | F(399, 9198) = 1.156 0.019 (400 categories) 2.3面板回歸xtset firm t, quarter
xtreg y i d ------------------------------------------------------------------------------ y | Coef. Std. Err. z P>|z| [95% Conf. Interval]-------------+---------------------------------------------------------------- i | .4349154 .0212192 20.50 0.000 .3933266 .4765042 d | 1.902249 .0207677 91.60 0.000 1.861545 1.942953 _cons | .192176 .0170907 11.24 0.000 .1586789 .2256731-------------+---------------------------------------------------------------- sigma_u | .04121238 sigma_e | 1.0138689 rho | .00164959 (fraction of variance due to u_i)------------------------------------------------------------------------------ xtreg y i d, fe ------------------------------------------------------------------------------ y | Coef. Std. Err. t P>|t| [95% Conf. Interval]-------------+---------------------------------------------------------------- i | 0 (omitted) d | 1.902249 .0207677 91.60 0.000 1.861539 1.942958 _cons | .3868007 .0140598 27.51 0.000 .3592403 .4143611-------------+---------------------------------------------------------------- sigma_u | .30216053 sigma_e | 1.0138689 rho | .08157474 (fraction of variance due to u_i)------------------------------------------------------------------------------
xtreg y i d, fe robust ------------------------------------------------------------------------------ | Robust y | Coef. Std. Err. t P>|t| [95% Conf. Interval]-------------+---------------------------------------------------------------- i | 0 (omitted) d | 1.902249 .0239592 79.40 0.000 1.855146 1.949351 _cons | .3868007 .0109813 35.22 0.000 .3652122 .4083891-------------+---------------------------------------------------------------- sigma_u | .30216053 sigma_e | 1.0138689 rho | .08157474 (fraction of variance due to u_i)------------------------------------------------------------------------------
xtreg y i d i.i##i.deststo xtreg_re ------------------------------------------------------------------------------ y | Coef. Std. Err. z P>|z| [95% Conf. Interval]-------------+---------------------------------------------------------------- i | .174383 .0284493 6.13 0.000 .1186234 .2301427 d | 1.647874 .0276586 59.58 0.000 1.593664 1.702084 1.i | 0 (omitted) 1.d | 0 (omitted) | i#d | 1 1 | .5684342 .041346 13.75 0.000 .4873976 .6494709 | _cons | .3087643 .0190313 16.22 0.000 .2714636 .3460649-------------+---------------------------------------------------------------- sigma_u | .05056003 sigma_e | 1.003664 rho | .00253126 (fraction of variance due to u_i)------------------------------------------------------------------------------
xtreg y i d i.i##i.d, feeststo xtreg_fe ------------------------------------------------------------------------------ y | Coef. Std. Err. t P>|t| [95% Conf. Interval]-------------+---------------------------------------------------------------- i | 0 (omitted) d | 1.647874 .0276586 59.58 0.000 1.593657 1.702091 1.i | 0 (omitted) 1.d | 0 (omitted) | i#d | 1 1 | .5684342 .041346 13.75 0.000 .4873869 .6494815 | _cons | .3868007 .0139183 27.79 0.000 .3595177 .4140837-------------+---------------------------------------------------------------- sigma_u | .22793566 sigma_e | 1.003664 rho | .0490464 (fraction of variance due to u_i)------------------------------------------------------------------------------F test that all u_i=0: F(399, 9198) = 1.16 Prob > F = 0.0194
2.4 結(jié)果輸出對比estout *, title('Actual parameter values are i = .19, d = 1.67, and i*d = .56') /// cells(b(star fmt(%9.3f)) se(par)) /// stats(N N_g, fmt(%9.0f %9.0g) label(N Groups)) /// legend collabels(none) varlabels(_cons Constant) keep(i d 1.i#1.d) ---------------------------------------------------------------------------- pooled areg xtreg_re xtreg_fe ----------------------------------------------------------------------------i 0.174*** 0.000 0.174*** 0.000 (0.028) (.) (0.028) (.) d 1.648*** 1.648*** 1.648*** 1.648*** (0.028) (0.028) (0.028) (0.028) 1.i#1.d 0.568*** 0.568*** 0.568*** 0.568*** (0.041) (0.041) (0.041) (0.041) ----------------------------------------------------------------------------N 9600 9600 9600 9600 Groups 400 400 ----------------------------------------------------------------------------* p<0.05, ** p<0.01, *** p<0.001
|
|