久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

Stata: 雙重差分的固定效應(yīng)模型 (DID)

 對對子不錯 2017-12-28

作者:張偉廣


Stata現(xiàn)場研討班即將開班(2018年1月13-21日,,北京)
Stata現(xiàn)場班-初級Stata現(xiàn)場班-高級


雙重差分法(DID)作為估計處理效應(yīng)的工具方法,,常被用來對政策實施的跨期效果進行評估,其本身也是一種固定效應(yīng)估計方法,。在不同應(yīng)用情形下,,該方法具有多種可供選擇的回歸命令,而由于有些應(yīng)用者對雙重差分模型設(shè)定的優(yōu)點和缺陷,,以及 stata 命令實現(xiàn)不夠了解,,使得該方法有被錯誤濫用的傾向。

在此借鑒參考 Using Stata to estimate difference-in-differences models with fixed effects by Nicholas Poggioli ([email protected]) ,,舉例從混合回歸,、 areg 回歸、面板回歸的隨機效應(yīng)和固定效應(yīng)等情形,,給出正確和錯誤模型設(shè)定的對比,,以期為雙重差分模型估計命令的正確選擇作參考。

簡要回顧雙重差分模型的設(shè)定形式:

DID模型設(shè)定 1

模型(1)為雙重差分模型的基本設(shè)定,。其中,, Gi 為分組虛擬變量(處理組=1,控制組=0),; Dt 為分期虛擬變量(政策實施后=1,,政策實施前=0);交互項 Gi*Dt 表示處理組在政策實施后的效應(yīng),,其系數(shù)即為雙重差分模型重點考察的處理效應(yīng),。

DID模型設(shè)定 2

模型(2)是加入個體固定效應(yīng) (ui),、時間固定效應(yīng)(λt),,以及其它控制變量(Xit)的雙重差分模型設(shè)定的一般形式,。

下面,我們通過一份模擬數(shù)據(jù)來對比分析不同估計方法的效果和偏誤,。

1.生成數(shù)據(jù)

生成企業(yè)數(shù)量

set obs 400gen firm=_n

時間跨度設(shè)定為24個季度(6年)

expand 24bysort firm: gen t=_n

設(shè)定事件沖擊發(fā)生在第14期

gen d=(t>=14)label var d '=1 if post-treatment'

設(shè)定處理組和對照組

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'

設(shè)定隨機變量

gen e = rnormal()label var e 'normal random variable'

2.驗證模型

處理效應(yīng)設(shè)定交互項系數(shù)為0.56

gen y = .3 + .19*i + 1.67*d + .56*i*d + e

2.1 混合回歸

  • 錯誤設(shè)定模型

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------------------------------------------------------------------------------

這一設(shè)定忽略了交互項,,對 id 的估計驗證有偏。

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------------------------------------------------------------------------------

穩(wěn)健標(biāo)準(zhǔn)差和對企業(yè)聚類方法對有偏估計并沒有矯正,。

  • 正確設(shè)定模型

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------------------------------------------------------------------------------

此時對交互項的估計,、對 id 的估計都是接近參數(shù)的真實值的。

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
  • 錯誤設(shè)定模型

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)------------------------------------------------------------------------------

此時 i 不能被估計,,因為在面板數(shù)據(jù)中的企業(yè)代碼是不隨時間變化的,。

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)------------------------------------------------------------------------------
  • 正確設(shè)定模型——隨機效應(yīng)

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)------------------------------------------------------------------------------

該隨機效應(yīng)模型與正確設(shè)定的混合回歸模型產(chǎn)生一致的估計結(jié)果。

  • 正確設(shè)定模型——固定效應(yīng)

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

該固定效應(yīng)模型對交互項和變量 d 的估計結(jié)果一致,,但對變量 i 的估計則被忽略,,因為其并不隨面板代碼而發(fā)生變化;

隨機效應(yīng)模型能夠估計出變量 i ,,因為該模型能夠包含企業(yè)變化,,且 i 也隨企業(yè)發(fā)生變化。

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

關(guān)于我們

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,,所有內(nèi)容均由用戶發(fā)布,,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式,、誘導(dǎo)購買等信息,,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,,請點擊一鍵舉報,。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多