其他
Bacon分解bacondecomp新+旧版本操作及ddtiming命令(三合一)操作应用
本文以及3月23日视频号里面所介绍的bacondecomp命令代码可以阅读原文进行下载查看。
之前视频里面给大家介绍了多时点DID进行Bacon分解,我们使用单边离婚法案案例为大家演示了bacondecomp新版本命令以及旧版本命令之间的区别,同时完整的展现了交叠DID处理效应是由分解出来的单时点DID处理效应的加权平均。详见3月23日推文:免费公开课:交叠DID偏误及Bacon分解+案例应用
这一讲里面我们为大家带来了另外一个Bacon分解的命令ddtiming,为大家展现bacondecomp新+旧版本操作及ddtiming命令。
内容简介:
案例应用 进行TWFE模型分析,areg命令+xtreg ddtiming进行Bacon分解 bacondecomp新+旧版本操作
简介
ddtiming是一个Stata命令,基于Goodman-Bacon(2021), 实现了双重差分(DD)估计随治疗时间变化的分解。双向固定效应DD模型是所有可能的两组/两周期DD估计量的加权平均。该命令生成2x2 DD估计值及其相关权重的散点图。
R用户可以使用名为bacondecomp的R包执行分解。
注意事项:Stata用户应该使用bacondecomp,这是Stata中Bacon分解的最新实现。
本视频里面用到的数据以及案例代码
要在Stata中安装ddtiming命令,可以在命令窗口中键入任意一种命令
net describe ddtiming, from(https://tgoldring.com/code)
net install ddtiming
*or type
net install ddtiming, from(https://tgoldring.com/code)
*- 例子-单边离婚法
* ddtiming可以复制Goodman-Bacon(2021)中的例子。
* 下载并加载无过错离婚法和女性自杀率的时间数据集(Stevenson & Wolfers, 2006):
net get ddtiming
use nofault_divorce.dta
*注意,我们还是使用的为3月23日视频里面介绍那个案例数据
use bacon_example.dta, clear
areg asmrs post i.year, a( stfips ) vce(robust)
结果省略
ddtiming asmrs post, i( stfips) t(year)
Calculating treatment times...
Calculating weights...
Estimating 2x2 diff-in-diff regressions...
Diff-in-diff estimate: -3.080
DD Comparison Weight Avg DD Est
-------------------------------------------------
Earlier T vs. Later C 0.111 -0.187
Later T vs. Earlier C 0.265 3.512
T vs. Never treated 0.240 -5.331
T vs. Already treated 0.384 -7.044
-------------------------------------------------
T = Treatment; C = Comparison
ssc install bacondecomp
checking bacondecomp consistency and verifying not already installed...
installing into c:\ado\plus\...
installation complete.
. adoedit bacondecomp
c:\ado\plus/b/bacondecomp.ado
. bacondecomp asmrs post , ddetail
Computing decomposition across 14 timing groups
including an always-treated group and a never-treated group
------------------------------------------------------------------------------
asmrs | Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
post | -3.079926 1.111656 -2.77 0.006 -5.258732 -.9011193
------------------------------------------------------------------------------
Bacon Decomposition
+---------------------------------------------------+
| | Beta TotalWeight |
|----------------------+----------------------------|
| Early_v_Late | 3.089867353 .0001259938 |
| Late_v_Early | -23.83420181 .0006803664 |
| Early_v_Late | .7286439538 .0008819564 |
| Late_v_Early | -8.258329391 .0045861736 |
| Early_v_Late | 2.404874802 .0005291738 |
| Late_v_Early | 22.15005112 .0022930868 |
| Early_v_Late | 1.676301956 .000566972 |
| Late_v_Early | -7.148348331 .00283486 |
| Early_v_Late | 4.613049507 .0004535776 |
| Late_v_Early | 26.58180046 .0018899067 |
| Early_v_Late | -7.006736755 .0009260543 |
| Late_v_Early | -5.394356728 .0033073366 |
| Early_v_Late | .6727053523 .0025198756 |
| Late_v_Early | -7.43382597 .012095402 |
| Early_v_Late | 3.899661064 .0022678879 |
| Late_v_Early | 27.04117584 .0090715515 |
| Early_v_Late | -7.521428585 .0061736949 |
| Late_v_Early | -6.398066521 .0211669536 |
| Early_v_Late | -3.244979858 .0015119253 |
| Late_v_Early | -3.630996227 .0045357758 |
| Early_v_Late | .1488796175 .0009449533 |
| Late_v_Early | -5.158778191 .0043467852 |
| Early_v_Late | -2.910137653 .0009071552 |
| Late_v_Early | 23.89071274 .0034774283 |
| Early_v_Late | -9.381551743 .0027781627 |
| Late_v_Early | -6.318483829 .009128249 |
| Early_v_Late | -8.437994003 .0009071552 |
| Late_v_Early | -6.468858719 .0026080712 |
| Early_v_Late | 4.291956902 .001700916 |
| Late_v_Early | 6.192469597 .0043467852 |
| Early_v_Late | 9.615415573 .0007559626 |
| Late_v_Early | .6682447195 .0033262358 |
| Early_v_Late | 5.732773304 .0007559626 |
| Late_v_Early | 29.61791611 .002771863 |
| Early_v_Late | 2.411342144 .002469478 |
| Late_v_Early | 4.052882671 .0077612166 |
| Early_v_Late | 5.130411148 .0009071552 |
| Late_v_Early | 4.886719704 .0024946767 |
| Early_v_Late | 8.392121315 .0022678879 |
| Late_v_Early | 10.78344917 .0055437261 |
| Early_v_Late | 3.15568161 .0003779813 |
| Late_v_Early | 3.873969555 .0008315589 |
| Early_v_Late | 3.482367754 .0004409782 |
| Late_v_Early | 4.239864349 .0018521086 |
| Early_v_Late | -7.72107935 .0004535776 |
| Late_v_Early | 28.58859062 .0015875215 |
| Early_v_Late | -8.404179573 .0015434237 |
| Late_v_Early | 3.740804911 .0046302713 |
| Early_v_Late | -9.093745232 .0006047701 |
| Late_v_Early | .6837824583 .0015875215 |
| Early_v_Late | 1.421976328 .001700916 |
| Late_v_Early | 11.66159821 .0039688039 |
| Early_v_Late | -16.38343239 .0003779813 |
| Late_v_Early | -6.338175297 .0007937608 |
| Early_v_Late | -14.61515999 .0001385932 |
| Late_v_Early | -7.964285851 .0002645869 |
| Early_v_Late | -3.567538977 .0015119253 |
| Late_v_Early | -13.05292702 .006047701 |
| Early_v_Late | -10.86773682 .0015875215 |
| Late_v_Early | 13.24829674 .0052917384 |
| Early_v_Late | -7.6874547 .0055563254 |
| Late_v_Early | -9.137350082 .0158752156 |
| Early_v_Late | -6.326669693 .0022678879 |
| Late_v_Early | -11.05425262 .0056697199 |
| Early_v_Late | 4.825609684 .0068036641 |
| Late_v_Early | .64386338 .0151192535 |
| Early_v_Late | 2.691236258 .001700916 |
| Late_v_Early | -4.655465126 .0034018321 |
| Early_v_Late | 1.836740971 .0008315589 |
| Late_v_Early | -6.611749649 .0015119253 |
| Early_v_Late | 20.30932999 .0002267888 |
| Late_v_Early | 7.368327141 .0003779813 |
| Early_v_Late | 3.358542204 .0006929658 |
| Late_v_Early | -4.764940262 .0023560837 |
| Early_v_Late | -9.930462837 .0007559626 |
| Late_v_Early | 19.64731598 .0021418943 |
| Early_v_Late | -2.845511436 .0027781627 |
| Late_v_Early | -.215427205 .0067469666 |
| Early_v_Late | -3.231632233 .0012095402 |
| Late_v_Early | -2.357027531 .0025702729 |
| Early_v_Late | 3.202227831 .0039688039 |
| Late_v_Early | 6.197752476 .0074966296 |
| Early_v_Late | -.0546139181 .0011339439 |
| Late_v_Early | .2491527498 .0019277048 |
| Early_v_Late | -4.581885338 .0006929658 |
| Late_v_Early | -6.757017612 .0010709471 |
| Early_v_Late | 23.70957756 .0003023851 |
| Late_v_Early | 21.65239143 .0004283788 |
| Early_v_Late | -5.129266739 .0007370636 |
| Late_v_Early | 2.485960007 .0009638524 |
| Early_v_Late | 9.392490387 .0009449533 |
| Late_v_Early | .7609612942 .0024568787 |
| Early_v_Late | -8.653765678 .0010583477 |
| Late_v_Early | 20.62852859 .0022930868 |
| Early_v_Late | 2.299735785 .0040129018 |
| Late_v_Early | 3.604630232 .0074525319 |
| Early_v_Late | 3.223866224 .0018143104 |
| Late_v_Early | 4.552188396 .0029482542 |
| Early_v_Late | 6.547305107 .006236692 |
| Late_v_Early | 10.9064064 .0090085548 |
| Early_v_Late | 5.205688 .0018899067 |
| Late_v_Early | 6.71902132 .0024568787 |
| Early_v_Late | -.8521057963 .0012473383 |
| Late_v_Early | -2.820950985 .0014741271 |
| Early_v_Late | 17.60421181 .0006047701 |
| Late_v_Early | 19.93760681 .0006551676 |
| Early_v_Late | -2.688749552 .001719815 |
| Late_v_Early | 9.5492239 .001719815 |
| Early_v_Late | -1.343767166 .0004031801 |
| Late_v_Early | 1.879976273 .0003275838 |
| Early_v_Late | -1.982551336 .0010079502 |
| Late_v_Early | 8.675222397 .0024190804 |
| Early_v_Late | -19.76277542 .0011339439 |
| Late_v_Early | 28.40373802 .0022678879 |
| Early_v_Late | -5.887892723 .0043215866 |
| Late_v_Early | 11.7344656 .0074084342 |
| Early_v_Late | -.348316431 .001965503 |
| Late_v_Early | 13.98102951 .0029482542 |
| Early_v_Late | 6.036512852 .0068036641 |
| Late_v_Early | 21.13029671 .0090715515 |
| Early_v_Late | 3.112169027 .0020788973 |
| Late_v_Early | 16.37677193 .0024946767 |
| Early_v_Late | .1411235332 .0013859315 |
| Late_v_Early | 9.925600052 .0015119253 |
| Early_v_Late | 16.27362823 .0006803664 |
| Late_v_Early | 29.59807777 .0006803664 |
| Early_v_Late | -1.641644478 .001965503 |
| Late_v_Early | 22.16219139 .0018143104 |
| Early_v_Late | -2.667479753 .0005039751 |
| Late_v_Early | 12.13856983 .0003779813 |
| Early_v_Late | 5.63313818 .0001259938 |
| Late_v_Early | 16.86439133 .0000755963 |
| Always_v_timing | -7.043688925 .3844322134 |
| Never_v_timing | -5.330906825 .2402701287 |
+---------------------------------------------------+
.
使用原始bacondecomp出现的新命令结果以及旧版本结果请查看上一期3月23日视频号内容。