天鹰(中南财大——博士研究生)
E-mail: yanbinglh@163.com
双重/三重差分建模步骤
- 输入数据
- 描述性分析
- 面板单位根检验(一般T>=20, T较小, 单位根检验方法功
效低)- 若变量平稳, 进行如下操作,
- 若是观测数据, 且控制组和实验组的分组, 并非随机分组,
是由其他因素(如个人因素) 所决定, 则可用面板倾向匹配得分中的处理办法
加以解决。
①分析处理变量是否受可能影响处理结果的因素的影
响。
若有影响, 则将忽略且与处理变量相关的变量, 纳入模型即可。
② 先定性分析, 如果控制组和实验组(即便在没有新政策的
情形) 有不同的时间趋势, 则选用三重差分法; 否则,
采用双重差分法, 即可。
③ 在使用三重差分法之前, 需要检验时间趋势差异是
否显著, 若显著不为0, 则可用三重差分法; 否则,
采用双重差分法即可。 (A、 B州时间趋势差异相似。 )
双重/三重差分Stata操作
- diff 命令介绍
ssc install diff, replace /----安装diff命令包--diff在2017年8月进行了更新----/
diff------双重差分法、倍差法、倍分法----三重差分法----------
diff outcome_var [if] [in] [weight] ,[ options]
outcome_var :结果变量。
----模型要求选项----
period(varname) :二元实验期变量(1:实验之后;0:实验之前)。注意:如果数据里
包含周期频率(如每月、每季度、每年等),
建议设定选项period(varname),
treated(varname) :二元处理变量(1:被处理;0:被控制、未处理)。
----选项----
cov(varlist) :为模型设定前定处理协变量。当kernel被选用时,这些变量将用于去
估计倾向得分。
kernel :执行基于核的双重差分倾向得分匹配。该选项将生成变量_weights和_ps,
_weights :来自核倾向得分匹配的权重;
_ps :pscore(varname)没有提供倾向得分时,报告得分。
且该选项要求使用id(varname),除非重复横截面设置。
id(varname) :kernel选项要求使用。
bw(#) :提供核函数的窗宽,默认为0.06。
ktype(kernel) :指定核函数的类型。分别为epanechnikov (默认),gaussian,
biweight,uniform 和 tricube。
rcs :表示核已设定(重复横截面),该选项不要求id(varname),选项rcs严格要求
cov(varlist)中的协变量不随时点变化。
qdid(quantile) :执行分位数双重差分估计,分位数从0.1-0.9,可以与kernel和cov选项
联合使用,qdid选项不支持加权稳健标准误估计
pscore(varname) :提供倾向得分。
logit :指定倾向得分采用logit估计,默认是probit。
support :在给定选项kernel的倾向得分下,执行diff命令。
addcov(varlist) :除了用于估计倾向得分的协变量外,指定额外的协变量。
在多频率数据的情形下,也可用于设定时点固定效应。
ddd(varname) :三重差分选项。treated(varname)被视为第1类;ddd(varname)视为第2类。
该选项不兼容kernel、test、qdid(quantile)。
----SE/Robust----
cluster(varname) :计算聚类标准误。
robust :计算稳健标准误。
bs :对参数和标准误采用bootstrap估计。
reps(int) :在bs被选用时,指定重复次数,默认为50。
----Balancing test----
test :采用balancing t检验,检验在基期时,协变量在控制组和实验组的均值是否有差异。
同时使用test和kernel选项,执行加权协变量的balancing t检验。
----报告----
report :当设定选项kernel时,显示所包含的协变量的推断或倾向得分的估计。
nostar :去掉p值的星号。
- 【没有协变量】的双重差分法
diff fte, t(treated) p(t)
DIFFERENCE-IN-DIFFERENCES ESTIMATION RESULTS
Number of observations in the DIFF-IN-DIFF: 801
Before After
Control: 78 77 155
Treated: 326 320 646
404 397
--------------------------------------------------------
Outcome var. | fte | S. Err. | |t| | P>|t|
----------------+---------+---------+---------+---------
Before | | | |
Control | 19.949 | | |
Treated | 17.065 | | |
Diff (T-C) | -2.884 | 1.135 | -2.54 | 0.011**
After | | | |
Control | 17.542 | | |
Treated | 17.573 | | |
Diff (T-C) | 0.030 | 1.143 | 0.03 | 0.979
| | | |
Diff-in-Diff | 2.914 | 1.611 | 1.81 | 0.071*
--------------------------------------------------------
R-square: 0.01
* Means and Standard Errors are estimated by linear regression
**Inference: *** p<0.01; ** p<0.05; * p<0.1
estimates store DD1
diff fte, t(treated) p(t) robust \\稳健性估计
DIFFERENCE-IN-DIFFERENCES ESTIMATION RESULTS
Number of observations in the DIFF-IN-DIFF: 801
Before After
Control: 78 77 155
Treated: 326 320 646
404 397
--------------------------------------------------------
Outcome var. | fte | S. Err. | |t| | P>|t|
----------------+---------+---------+---------+---------
Before | | | |
Control | 19.949 | | |
Treated | 17.065 | | |
Diff (T-C) | -2.884 | 1.403 | -2.05 | 0.040**
After | | | |
Control | 17.542 | | |
Treated | 17.573 | | |
Diff (T-C) | 0.030 | 1.023 | 0.03 | 0.976
| | | |
Diff-in-Diff | 2.914 | 1.737 | 1.68 | 0.094*
--------------------------------------------------------
R-square: 0.01
* Means and Standard Errors are estimated by linear regression
**Robust Std. Errors
**Inference: *** p<0.01; ** p<0.05; * p<0.1
estimates store DD2
- bootstrapped 稳健标准误:
quietly diff fte, t(treated) p(t) bs rep(50)
estimates store DD3
esttab DD1 DD2 DD3 , ar2(%8.4f) se(%8.4f) nogap brackets aic bic mtitles replace
------------------------------------------------------------
(1) (2) (3)
DD1 DD2 DD3
------------------------------------------------------------
t -2.407 -2.407 -2.407
[1.4463] [1.5941] [1.4815]
treated -2.884* -2.884* -2.884*
[1.1348] [1.4033] [1.3295]
_diff 2.914 2.914 2.914
[1.6105] [1.7368] [1.6940]
_cons 19.95*** 19.95*** 19.95***
[1.0194] [1.3173] [1.2890]
------------------------------------------------------------
N 801 801 801
adj. R-sq 0.0043 0.0043 0.0043
AIC 5797.6 5797.6 5797.6
BIC 5816.4 5816.4 5816.4
------------------------------------------------------------
Standard errors in brackets
* p<0.05, ** p<0.01, *** p<0.001
双重差分Stata操作
- 【有协变量】的双重差分法
diff fte, t(treated) p(t) cov(bk kfc roys)
DIFFERENCE-IN-DIFFERENCES WITH COVARIATES
DIFFERENCE-IN-DIFFERENCES ESTIMATION RESULTS
Number of observations in the DIFF-IN-DIFF: 801
Before After
Control: 78 77 155
Treated: 326 320 646
404 397
--------------------------------------------------------
Outcome var. | fte | S. Err. | |t| | P>|t|
----------------+---------+---------+---------+---------
Before | | | |
Control | 21.161 | | |
Treated | 18.837 | | |
Diff (T-C) | -2.324 | 1.031 | -2.25 | 0.024**
After | | | |
Control | 18.758 | | |
Treated | 19.369 | | |
Diff (T-C) | 0.611 | 1.037 | 0.59 | 0.556
| | | |
Diff-in-Diff | 2.935 | 1.460 | 2.01 | 0.045**
--------------------------------------------------------
R-square: 0.19
* Means and Standard Errors are estimated by linear regression
**Inference: *** p<0.01; ** p<0.05; * p<0.1
estimates store DDCOV1
- 报告协变量的估计结果
diff fte, t(treated) p(t) cov(bk kfc roys) report
diff fte, t(treated) p(t) cov(bk kfc roys) report bs rep(200)
DIFFERENCE-IN-DIFFERENCES ESTIMATION RESULTS
Number of observations in the DIFF-IN-DIFF: 801
Before After
Control: 78 77 155
Treated: 326 320 646
404 397
Report - Covariates and coefficients:
-------------------------------------------------------------------
Variable(s) | Coeff. | Std. Err. | z | P>|z|
---------------------+------------+-----------+---------+----------
bk | 0.917 | 0.947 | 0.968 | 0.333
kfc | -9.205 | 0.883 | -10.420 | 0.000
roys | -0.897 | 1.021 | -0.878 | 0.380
-------------------------------------------------------------------
Bootstrapped Standard Errors
--------------------------------------------------------
Outcome var. | fte | S. Err. | |t| | P>|t|
----------------+---------+---------+---------+---------
Before | | | |
Control | 21.161 | | |
Treated | 18.837 | | |
Diff (T-C) | -2.324 | 1.301 | -1.79 | 0.074*
After | | | |
Control | 18.758 | | |
Treated | 19.369 | | |
Diff (T-C) | 0.611 | 0.944 | 0.65 | 0.518
| | | |
Diff-in-Diff | 2.935 | 1.583 | 1.85 | 0.064*
--------------------------------------------------------
R-square: 0.19
Means and Standard Errors are estimated by linear regression
*** p<0.01; ** p<0.05; * p<0.1
estimates store DDCOV2
diff fte, t(treated) p(t) cov(bk kfc roys) robust
DIFFERENCE-IN-DIFFERENCES ESTIMATION RESULTS
Number of observations in the DIFF-IN-DIFF: 801
Before After
Control: 78 77 155
Treated: 326 320 646
404 397
--------------------------------------------------------
Outcome var. | fte | S. Err. | |t| | P>|t|
----------------+---------+---------+---------+---------
Before | | | |
Control | 21.161 | | |
Treated | 18.837 | | |
Diff (T-C) | -2.324 | 1.254 | -1.85 | 0.064*
After | | | |
Control | 18.758 | | |
Treated | 19.369 | | |
Diff (T-C) | 0.611 | 0.900 | 0.68 | 0.497
| | | |
Diff-in-Diff | 2.935 | 1.543 | 1.90 | 0.058*
--------------------------------------------------------
R-square: 0.19
* Means and Standard Errors are estimated by linear regression
**Robust Std. Errors
**Inference: *** p<0.01; ** p<0.05; * p<0.1
estimates store DDCOV3
esttab DDCOV1 DDCOV2 DDCOV3 using testlddcov.doc, ar2(%8.4f) se(%8.4f) nogap brackets aic bic mtitles replace
------------------------------------------------------------
(1) (2) (3)
DDCOV1 DDCOV2 DDCOV3
------------------------------------------------------------
t -2.403 -2.403 -2.403
[1.3113] [1.4260] [1.4103]
treated -2.324* -2.324 -2.324
[1.0307] [1.3008] [1.2537]
_diff 2.935* 2.935 2.935
[1.4601] [1.5831] [1.5434]
bk 0.917 0.917 0.917
[0.8888] [0.9474] [0.9383]
kfc -9.205*** -9.205*** -9.205***
[1.0055] [0.8833] [0.8991]
roys -0.897 -0.897 -0.897
[0.9674] [1.0211] [1.0411]
_cons 21.16*** 21.16*** 21.16***
[1.1419] [1.2754] [1.3071]
------------------------------------------------------------
N 801 801 801
adj. R-sq 0.1817 0.1817 0.1817
AIC 5643.4 5643.4 5643.4
BIC 5676.2 5676.2 5676.2
------------------------------------------------------------
Standard errors in brackets
* p<0.05, ** p<0.01, *** p<0.001
网友评论