引用信息:

陈强, 齐霁, 颜冠鹏. 双重差分法的安慰剂检验:一个实践的指南[J]. 管理世界, 2025, 41(02): 181-220.

双重差分法(difference-in-differences,DID)是实证研究中最常用的因果推断方法之一。越来越多的研究通过“安慰剂检验”进一步探讨遗漏混杂因素及其可能引发的偏差,一般通过构造伪干预组或伪干预时间进行安慰剂检验。

陈强等(2025)《双重差分法的安慰剂检验:一个实践的指南》一文系统梳理了标准 DID、交叠 DID、连续 DID、队列 DID 等多种差分法的安慰剂检验思路和方法,并提供了标准 DID 和交叠 DID 的安慰剂检验程序。本文对将对其提供的安慰剂检验程序进行梳理和复现,推荐大家先阅读原论文,再结合推文附件中的代码进行复现。

附件下载链接:百度网盘链接

全文 1.8 万字,包含大量公式、代码和图片,建议在桌面端阅读体验更佳。

一、标准 DID

在标准 DID 模型中,政策冲击同步发生,且不存在政策退出,一旦受到处理,则在样本期间一直受到处理。这种 DID 设计包含两组(即干预组和控制组)与两时段(干预前和干预后)的数据。

标准 DID 估计下,处理组的平均处理效应:

\[ \begin{align} ATT = \text{E} [y_{it}(1) -y_{it}(0) \ | \ D_{it}=1 ] \end{align} \]

对于标准 DID,我们通常使用双重固定效应模型进行估计:

\[ \begin{align} y_{it}= \delta D_{it} + \beta Z_{it} + u_{it} + \lambda _t + \varepsilon_{it} \end{align} \]

其中,\(y_{it}\) 表示被解释变量,\(D_{it}\) 表示政策干预,\(Z_{it}\) 表示控制变量;\(\delta\) 即为上面待估计 ATT;\(u_{it}\) 为个体固定效应,\(\lambda_t\) 为时间固定效应,\(\varepsilon_{it}\) 为随机扰动项。

二、标准 DID 的安慰剂检验

陈强等(2025)将安慰剂检验总结为四种类型:时间安慰剂、个体安慰剂、混合安慰剂和外部安慰剂。前三种安慰剂检验无需依赖外部数据,因此适用范围更广,并且有标准化的检验程序。外部安慰剂检验则需根据具体选题和数据结构灵活设计,通常没有标准化的检验程序。因此,本文重点介绍前三种安慰剂检验的操作步骤和代码实现。

1. 标准 DID 的时间安慰剂检验

1.1 简要原理

时间安慰剂检验的本质是构造伪干预时间。 在进行时间安慰剂检验时,可选择除第 1 期外的处理前某期(比如第 \(s\) 期)作为伪干预时间,从而定义如下伪处理变量:
\[ \begin{align} D_{it}^* = \begin{cases} 1 & \text{若 } i \in \text{处理组, 且 } t \geq s \\ 0 & \text{其他} \end{cases} \end{align} \]

对于处理前样本,恒有 \(D_{it} =0\)。因此,对于处理前样本,\(D_{it}^ * =1\) 仅表明接受了安慰剂(比如病人吃了不含药物的糖丸),但并未受到处理,故本文将伪处理变量 \(D_{it}^ *\) 称为“安慰剂变量”(placebo variable)。 更一般地,\(D_{it}^ * =1\) 仅表示个体 \(i\) 在时期 \(t\) 接受了安慰剂,而无论其是否受到处理(也可能受到处理)。 将上述方程所定义的安慰剂变量 \(D_{it}^ *\) 代入方程(2),且限制仅使用处理前样本,即可进行时间安慰剂检验。

如下图所示,假定从 \(t=6\) 期开始,样本 \(i=3\)\(i=4\) 接受干预。我们可以使用 \(1 \leq t \leq 5\) 的样本进行时间安慰剂检验,将未接受干预的 \(t=4\)\(t=5\) 设置为伪干预时间,检验干预组在伪干预时间内是否有显著的效应。如果伪干预时间的效应显著,则说明可能存在时变的遗漏因素。

标准 DID 的时间安慰剂检验

1.2 代码实现

使用陈强等(2025)开发的命令 didplacebo ,可以对标准 DID 进行时间安慰剂检验。

1
2
3
4
5
6
7
8
9
10
11
** 安装 didplacebo 命令
ssc install didplacebo, replace

** 调用 Cao and Chen (2022) 的《漕粮海运》数据集
use cao_chen.dta, clear
xtset county year

** DID 估计和时间安慰剂检验
reghdfe rebel canal_post, absorb(i.county i.year) cluster(county)
estimates store did_cao_chen
didplacebo did_cao_chen, treatvar(canal_post) pbotime(1(1)10)

我们使用了 ssc install didplacebo, replace 安装 didplacebo 命令,而没有使用原论文中的 all选项来同时安装命令和下载数据集。这是因为数据集文件较大,网络不佳可能导致 Stata 卡死甚至崩溃。

安装程序和下载数据

注意: 使用ssc install安装的reghdfe 命令不一定是最新版本,建议前往作者 Github 主页查看reghdfe 命令的使用说明和下载方式,链接:https://github.com/sergiocorreia/reghdfe

1.3 结果展示

下面是使用高维固定效应 reghdfe 的估计结果:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
. reghdfe rebel canal_post, absorb(i.county i.year) cluster(county)
(MWFE estimator converged in 2 iterations)

HDFE Linear regression Number of obs = 140,432
Absorbing 2 HDFE groups F( 1, 535) = 5.23
Statistics robust to heteroskedasticity Prob > F = 0.0226
R-squared = 0.0308
Adj R-squared = 0.0253
Within R-sq. = 0.0002
Number of clusters (county) = 536 Root MSE = 0.3848

(Std. err. adjusted for 536 clusters in county)
------------------------------------------------------------------------------
| Robust
rebel | Coefficient std. err. t P>|t| [95% conf. interval]
-------------+----------------------------------------------------------------
canal_post | .0380143 .016621 2.29 0.023 .0053639 .0706647
_cons | .0313251 .0007227 43.35 0.000 .0299054 .0327447
------------------------------------------------------------------------------

Absorbed degrees of freedom:
-----------------------------------------------------+
Absorbed FE | Categories - Redundant = Num. Coefs |
-------------+---------------------------------------|
county | 536 536 0 *|
year | 262 0 262 |
-----------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation

我们将上述实证结果保存至 did_cao_chen.dta数据集,然后将处理时间分别滞后 1 至 10 期,使用 didplacebo 命令对上述实证结果进行时间安慰剂检验。

补充:什么是滞后?什么是提前?

  • “滞后”是某个变量的过去取值,即用过去的信息来解释当前或未来的结果。对 \(X\) 滞后 1 期,其估计方程通常表示为 \(Y _t = \beta_0 +\beta_1 X_{t-1} + \varepsilon_t\)
  • “提前”是某个变量的未来取值,即用未来的信息来解释当前或过去的结果。对 \(X\) 提前 1 期,其估计方程通常表示为 \(Y _t = \beta_0 +\beta_1 X_{t+1} + \varepsilon_t\)

使用 didplacebo 命令进行时间安慰剂检验,会得到一个实证结果表和包含置信区间的检验结果图。下面的实证结果表显示,如果将干预时间滞后 1-10 期,回归结果均不显著。从下方的图中可以更加直观地看到时间安慰剂检验结果,各个滞后期的 95% 结果置信区间均包含 0,表明滞后 1-10 期,干预政策均无显著的影响,通过了安慰剂检验。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
. didplacebo did_cao_chen, treatvar(canal_post) pbotime(1(1)10)

Implementing in-time placebo test using fake treatment time shifted back by 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 periods respectively.

Results of in-time placebo test using fake treatment times:
------------------------------------------------------------------------------
| Coefficient Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
canal_post |
L1. | .0237488 .0323933 0.73 0.463 -.039741 .0872386
L2. | -.0018263 .0177129 -0.10 0.918 -.0365429 .0328903
L3. | -.0072098 .0123804 -0.58 0.560 -.0314749 .0170552
L4. | .0365355 .0313244 1.17 0.243 -.0248592 .0979302
L5. | .0193318 .0257651 0.75 0.453 -.0311668 .0698304
L6. | .0085124 .0216505 0.39 0.694 -.0339218 .0509467
L7. | .0156334 .0202899 0.77 0.441 -.0241341 .055401
L8. | .0412773 .0259976 1.59 0.112 -.0096771 .0922318
L9. | .0348408 .0231507 1.50 0.132 -.0105337 .0802153
L10. | .0283695 .020891 1.36 0.174 -.0125762 .0693151
------------------------------------------------------------------------------
Note: The standard errors are computed using the same method as specified by the Stata command previously used for DID estimation.
For example, if "xtreg, r" or "reghdfe, cluster(clustvar)" is used, then cluster-robust standard errors are reported.

Finished.

标准 DID 的时间安慰剂检验图

2. 标准 DID 的个体安慰剂检验

2.1 简要原理

个体安慰剂检验(论文中称为“空间安慰剂检验”)的本质是构造伪干预组。 该检验关注“精确原假设”(sharp null hypothesis),原假设为所有处理个体的处理效应均为 0,即:
\[ H_0: \ y_{it}(1) - y_{it}(0) = 0 \quad \text{(对于所有 } D_{it} = 1 \text{)} \]

在此精确原假设下,所有个体的处理效应都是 0,而潜在结果均等于观测结果。此时,原估计方程的 \(\delta =0\),因此该假设可以被转化为 \(H_0:\ \delta = 0\)

个体安慰剂检验可以使用“随机”或“非随机”的方式构造伪干预组。这里使用更加常见的随机抽样产生的安慰剂样本进行 DID 估计。 为保证上述的个体安慰剂检验结果不依赖于特定样本,可以使用 Bootstrap 重复抽样 500 次或者 1000 次进行估计。

标准 DID 的个体安慰剂检验

2.2 代码实现

我们仍然使用 Cao and Chen (2022) 的《漕粮海运》数据集进行个体安慰剂检验。检验时,设置 Bootstrap 次数为 500 次。为保证结果可复现,将随机种子设置为 seed(1)

1
didplacebo did_cao_chen, treatvar(canal_post) pbounit rep(500) seed(1)

2.3 结果展示

个体安慰剂检验的结果会提供一个估计结果表和估计系数的密度分布图。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
. didplacebo did_cao_chen, treatvar(canal_post) pbounit rep(500) seed(1)

Implementing in-space placebo test using fake treatment units:
Simulations (500):.........10.........20.........30.........40.........50.........60.........70.........80.........90.........100......
> ...110.........120.........130.........140.........150.........160.........170.........180.........190.........200.........210.......
> ..220.........230.........240.........250.........260.........270.........280.........290.........300.........310.........320........
> .330.........340.........350.........360.........370.........380.........390.........400.........410.........420.........430.........
> 440.........450.........460.........470.........480.........490.........500
Results of in-space placebo test results using fake treatment units:
--------------------------------------------------------------
| | P-value
| Coefficient | Two-sided Left-sided right-sided
-----------+-------------+------------------------------------
canal_post | 0.038014 | 0.0080 0.9920 0.0080
--------------------------------------------------------------
Note: (1) The two-sided p-value is the frequency that the absolute values of the placebo effects are greater than or equal to the
absolute value of estimated treatment effect.
(2) The left-sided (right-sided) p-value is the frequency that the placebo effects are smaller (greater) than or equal to the
estimated treatment effect.

Finished.

需要注意的是,估计结果表的重点不在于前面的估计系数 0.038014,而是后面的 P 值。

  • 结果表中的系数是上面使用 reghdfe 命令进行 DID 估计得到的系数。
  • 上表中包含三个 P 值,分别是双边检验、左边检验和右边检验的 P 值。双边检验的目的是估计系数的绝对值 \(|\hat {\delta}^*|\) 是否显著区别于 0,左边检验是检验估计系数是否满足 \(\hat {\delta}^* \lt 0\),右边检验是检验估计系数是否满足 \(\hat {\delta}^* \gt 0\)

上面的估计系数为正数,我们应该关注双边检验和右边检验的结果。 估计结果表显示,双边检验和右侧检验均在 1% 水平上显著,表明基准回归系数为正是稳健的。同时基于绘制的个体安慰剂检验密度分布图,可以发现真实的回归系数(黑色竖线)位于检验结果模拟分布的右侧长尾处,表明基准回归结果为正是稳健的。

同理,如果估计系数是负数,我们应该关注双边检验和左边检验的结果。

标准 DID 的个体安慰剂检验图

3. 标准 DID 的混合安慰剂检验

3.1 简要原理

做完上面的时间和个体的安慰剂检验还是不够过瘾,是不是还存在同时随个体和时间变化的遗漏因素影响估计结果呢?我们可以将上面时间和个体安慰剂检验组合起来,同时构造伪干预组和干预时间,进行混合安慰剂检验。

标准 DID 的混合安慰剂检验

3.2 代码实现

didplacebo 命令可以用于标准 DID 和交叠 DID 的安慰剂检验,在进行混合安慰剂检验时,需要指定 DID 的类型。我们设置 pbomix() 选项为 pbomix(1),即适用于标准 DID 的混合安慰剂检验。为保证结果可复现,将随机种子设置为 seed(1)

1
didplacebo did_cao_chen, treatvar(canal_post) pbomix(1) seed(1)

3.3 结果展示

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
. didplacebo did_cao_chen, treatvar(canal_post) pbomix(1) seed(1)

Implementing mixed placebo test for standard DID (version 1) using both fake treatment units and times:
-------------------------------------------------------------------------
The number of units randomly | The range within which fake
selected as fake treatment units | treatment times are randomly selected
----------------------------------+--------------------------------------
73 | [1651, 1911]
-------------------------------------------------------------------------
Simulations (500):.........10.........20.........30.........40.........50.........60.........70.........80.........90.........100......
> ...110.........120.........130.........140.........150.........160.........170.........180.........190.........200.........210.......
> ..220.........230.........240.........250.........260.........270.........280.........290.........300.........310.........320........
> .330.........340.........350.........360.........370.........380.........390.........400.........410.........420.........430.........
> 440.........450.........460.........470.........480.........490.........500
Results of mixed placebo test for standard DID (version 1) using both fake treatment units and times:
--------------------------------------------------------------
| | P-value
| Coefficient | Two-sided Left-sided right-sided
-----------+-------------+------------------------------------
canal_post | 0.038014 | 0.0060 0.9960 0.0040
--------------------------------------------------------------
Note: (1) The two-sided p-value is the frequency that the absolute values of the placebo effects are greater than or equal to the
absolute value of estimated treatment effect.
(2) The left-sided (right-sided) p-value is the frequency that the placebo effects are smaller (greater) than or equal to the
estimated treatment effect.

Finished.

上面混合安慰剂检验结果的解读方法,和个体安慰剂检验是基本一致的。由于基准回归系数是正的,因此我们重点关注双边检验和右边检验,可以发现其 P 值均小于 0.01,在 1% 水平上通过了混合安慰剂检验,即基准回归估计的正系数是稳健的。同时我们将真实的估计系数放到密度分布图中,可以发现真实的估计系数位于右侧长尾处,再次验证基准回归结果是稳健的。

标准 DID 的混合安慰剂检验图

4. 标准 DID 的外部安慰剂检验

外部安慰剂检验则利用样本之外的外部信息进行安慰剂检验,具体包括 3 种方式,即更换结果变量、更换处理变量与更换样本。

更换结果变量: 在理论上,可以预期处理变量对于其他结果变量不应有任何作用。若更换结果变量后,依然发现显著的处理效应(而理论上此处理效应为 0),则说明此结果可能为时变的混杂因素所驱动。

更换处理变量: 其本质是考察竞争性政策的影响,用检验竞争性政策对结果变量无显著影响来论证原处理变量是有效的。若更换处理变量后未发现显著效应(而理论上应为正向或负向显著),则表明原处理效应结果不太可能由样本间不可观测差异所驱动。这一检验的思路与工具变量的排他性检验类似。

更换样本: 若更换样本后处理效应不再显著(而理论上应为 0),则表明原估计结果较难由特定样本选择或时间设定所驱动。

三、交叠 DID 的安慰剂检验

1. 交叠 DID

与标准 DID 不同,交叠 DID 允许个体在不同时间受到处理,但一旦进入处理状态,则在样本期间持续受到处理,不允许政策退出。比如,新一轮承包耕地确权登记就是适合交叠 DID 评估的政策,一个地区在纳入承包耕地确权登记试点后,不会退出试点名单。

补充:新一轮承包耕地确权登记

2009 年,全国有 3 个村开始试点承包耕地确权登记;到 2010 年,共有 8 个村参与试点;2011-2013 年期间,全国共有上百个县成为试点,一个县一般选取一个或多个乡镇进行试点;2014 年,山东、安徽和四川开始整省试点;2015 年新增江苏、江西、湖北、湖南、甘肃、宁夏、吉林、贵州、河南等 9 个省份作为试点整省推进,此时已有累计 12 个省份整省推进承包耕地确权。随后,承包耕地确权的范围逐步扩大,到 2019 年,全国农村承包耕地确权登记颁证工作基本进入收尾阶段,仅有少数地区未完成。

参考: 杨广亮, 王军辉. 新一轮农地确权、农地流转与规模经营——来自 CHFS 的证据[J]. 经济学(季刊), 2022, 22(01): 129-152.

交叠 DID 的回归方程仍可采用标准形式表达,但由于每个个体的处理起始时间不同,处理变量 \(D_{it}\) 无法表示为统一的交互项 \(\text{treat}_i \times \text{post}_t\);其传统估计方法为双向固定效应(TWFE)估计量,对应的安慰剂检验也通常基于 TWFE 实施。与标准 DID 类似,交叠 DID 的安慰剂检验也可分为时间、空间、混合与外部安慰剂检验四种类型。由于标准 DID 是交叠 DID 的特例(前者只有两个组群,即处理组与控制组;而后者可有多个组群,根据受处理时间而分类),故标准 DID 的安慰剂检验也可视为交叠 DID 安慰剂检验的特例。

\[ \begin{align} y_{it}= \delta D_{it} + \beta Z_{it} + u_{it} + \lambda _t + \varepsilon_{it} \end{align} \]

其中,\(y_{it}\) 表示被解释变量,\(D_{it}\) 表示政策干预,\(Z_{it}\) 表示控制变量;\(\delta\) 即为上面待估计 ATT;\(u_{it}\) 为个体固定效应,\(\lambda_t\) 为时间固定效应,而 \(\varepsilon_{it}\) 为随机扰动项。

1.1 交叠 DID 的时间安慰剂检验

交叠 DID 的时间安慰剂检验通过滞后处理时间设定伪处理期,在剔除真实处理后观测值后进行 DID 估计,以检验在未实际受处理前是否已存在显著效应,从而识别潜在的时变混杂因素。如下图所示,删除原干预组处理后的样本(\(i=3\)\(5 \leq t\leq 8\)\(i=4\)\(7 \leq t\leq 8\)),并将干预时间滞后 2 期。

交叠 DID 的时间安慰剂检验

1.2 交叠 DID 的个体安慰剂检验

类似于标准 DID,在交叠 DID 中,也可以通过重新分配干预组和控制组,实现个体安慰剂检验。具体来看,根据样本中个体开始接受处理的不同时间,可将个体分为若干“组群”(cohorts)。交叠 DID 的空间安慰剂检验使用伪处理组,但不改变处理时间。 与标准 DID 类似,根据产生伪处理组的不同方式,交叠 DID 的空间安慰剂检验分为“非随机”与“随机”两种。下图是使用“随机”置换手段构造伪干预组,将个体 \(i=3\) 的干预行为置换到样本 \(i=4\) 上,将个体 \(i=4\) 的干预行为置换到样本 \(i=2\) 上,然后检验政策干预的效果是否仍然显著。

交叠 DID 的个体安慰剂检验

1.3 交叠 DID 的混合安慰剂检验

交叠 DID 的混合安慰剂检验有两种方法:一是不再保持“组群”结构,实行“无约束”的混合安慰剂检验;二是保持“组群”结构,实行“有约束”的混合安慰剂检验。

1.3.1 无约束的混合安慰剂检验

对于无约束的混合安慰剂检验,其原理是:对于样本中的每位个体,在指定范围内随机抽取一个伪干预时间 \(t^*_{i}\) 得到安慰剂样本,进行 DID 估计,并使用安慰剂效应的分布进行统计推断。

交叠 DID 的无约束混合安慰剂检验

1.3.2 有约束的混合安慰剂检验

有约束的混合安慰剂检验通过在保持组群规模不变的前提下随机分配伪干预时间,构造安慰剂样本并重复估计,以检验真实处理效应的显著性是否超过随机扰动所致。例如,Li et al.(2016)采用有约束的混合安慰剂检验,虽使用了伪干预时间,但仍保持组群结构 \(\{N_1, \ldots, N_G\}\) 不变。该文使用我国 1995~2012 年县级面板数据,考察分批推出的“省管县”改革对各县经济绩效的影响,交叠 DID 估计结果发现显著的负效应。在进行有约束的混合安慰剂检验时,首先从 1996~2011 年区间随机抽取 8 个伪干预时间 \(\{t_1, \ldots, t_8\}\)(原始样本中省管县改革仅发生于 8 个年份)。其次,从全样本中随机抽取 \(N_1\) 个县,将其伪干预时间设为 \(t_1\);再从剩余 \((N - N_1)\) 个县中随机抽取 \(N_2\) 个县,将其伪干预时间设为 \(t_2\);以此类推。重复此过程 500 次,经 DID 估计得到安慰剂效应的分布。结果发现处理效应估计值小于所有安慰剂效应的取值,故强烈拒绝“处理效应为 0”的原假设。

2. 代码实现

由于 DID 系列方法更新太快,陈强等(2025)主要基于 xtreg 命令,开发 didplacebo 命令进行安慰剂检验。本章使用基于 xtreg 开发的高维固定效应 reghdfe 命令进行 DID 估计。交叠 DID 中更常用的 csdid 命令的安慰剂检验,相关代码和结果将在第四章中展示。

在进行混合安慰剂检验时,针对交叠 DID,需要指定 pbomix() ​选项为 pbomix(2) ​或 pbomix(3)。其中,pbomix(2) ​适用于交叠 DID 的无约束情形 pbomix(3) ​适用于交叠 DID 的有约束情形。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
** 调用案例数据集
use bbb.dta, clear
xtset statefip wrkyr

** 交叠 DID 估计
global cov "gsp_pc_growth prop_blacks prop_dropouts prop_female_headed unemploymentrate"
xtreg log_gini _intra $cov i.wrkyr, fe r
reghdfe log_gini _intra $cov, absorb(statefip wrkyr) vce(robust)
estimates store did_bbb

** 时间安慰剂检验
didplacebo did_bbb, treatvar(_intra) pbotime(1(1)10)

** 个体安慰剂检验
didplacebo did_bbb, treatvar(_intra) pbounit rep(500) seed(1)

** 无约束的混合安慰剂检验
didplacebo did_bbb, treatvar(_intra) pbomix(2) seed(1)

** 有约束的混合安慰剂检验
didplacebo did_bbb, treatvar(_intra) pbomix(3) seed(1)

3. 结果展示

3.1 交叠 DID 的时间安慰剂检验

交叠 DID 时间安慰剂检验的命令和结果汇报与标准 DID 一致。从下面的表可以发现,在滞后 2、3 和 6 年的时候,\(P\lt 0.05\),但在滞后其他年份是不显著的。这说明平行趋势可能并不完全满足,大多数年份通过了安慰剂检验。在下面的图中,可以更直观地看到估计系数和 95% 置信区间。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
. didplacebo did_bbb, treatvar(_intra) pbotime(1(1)10)

Implementing in-time placebo test using fake treatment time shifted back by 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 periods respectively.

Results of in-time placebo test using fake treatment times:
------------------------------------------------------------------------------
| Coefficient Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
_intra |
L1. | .0068046 .006336 1.07 0.283 -.0056136 .0192228
L2. | .0134762 .0045357 2.97 0.003 .0045865 .022366
L3. | .0112213 .0044049 2.55 0.011 .0025879 .0198546
L4. | .0053115 .0045254 1.17 0.241 -.003558 .014181
L5. | .0071231 .0046218 1.54 0.123 -.0019354 .0161816
L6. | .0113446 .0051368 2.21 0.027 .0012767 .0214126
L7. | .002451 .0051785 0.47 0.636 -.0076986 .0126007
L8. | -.0009252 .005231 -0.18 0.860 -.0111778 .0093275
L9. | .0040415 .0054689 0.74 0.460 -.0066773 .0147603
L10. | .0071297 .0059886 1.19 0.234 -.0046078 .0188671
------------------------------------------------------------------------------
Note: The standard errors are computed using the same method as specified by the Stata command previously used for DID estimation. For example, if "xtreg,
r" or "reghdfe, cluster(clustvar)" is used, then cluster-robust standard errors are reported.

Finished.

交叠 DID 的时间安慰剂检验图

3.2 交叠 DID 的个体安慰剂检验

使用 pbounit ​指定进行个体安慰剂检验,然后将 Bootstrap 次数设置为 500 次,估计结果如下所示。

交叠 DID 个体安慰剂检验结果解读与上面标准 DID 类似,也是关注表中的 p 值、图中黑色实线的位置。基准回归的估计系数是 -0.017724,为负数,因此这里关注双边检验和左边检验的 p 值。双边检验 \(P=0.0120\),表明在 5% 水平上,估计系数的绝对值是显著区别于 0 的;左边检验 \(P=0.0060\),表明在 1% 水平上,估计系数是显著小于 0 的。同时,基于绘制的个体安慰剂检验密度分布图,可以发现真实的回归系数(黑色竖线)位于检验结果模拟分布的左侧长尾处,表明基准回归结果为负是稳健的。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
. didplacebo did_bbb, treatvar(_intra) pbounit rep(500) seed(1)

Implementing in-space placebo test using fake treatment units:
Simulations (500):.........10.........20.........30.........40.........50.........60.........70.........80.........90.........100.........110.........120.....
> ....130.........140.........150.........160.........170.........180.........190.........200.........210.........220.........230.........240.........250.....
> ....260.........270.........280.........290.........300.........310.........320.........330.........340.........350.........360.........370.........380.....
> ....390.........400.........410.........420.........430.........440.........450.........460.........470.........480.........490.........500
Results of in-space placebo test results using fake treatment units:
--------------------------------------------------------------
| | P-value
| Coefficient | Two-sided Left-sided right-sided
-----------+-------------+------------------------------------
_intra | -0.017724 | 0.0120 0.0060 0.9940
--------------------------------------------------------------
Note: (1) The two-sided p-value is the frequency that the absolute values of the placebo effects are greater than or equal to the absolute value of
estimated treatment effect.
(2) The left-sided (right-sided) p-value is the frequency that the placebo effects are smaller (greater) than or equal to the estimated treatment
effect.

Finished.

交叠 DID 的个体安慰剂检验图

3.3 交叠 DID 的混合安慰剂检验

3.3.1 无约束的混合安慰剂检验

指定 pbomix(2) ​以进行无约束的混合安慰剂检验,结果展示与交叠 DID 的个体安慰剂检验类似。

在每一次的估计中,都抽取了 49 个伪干预组个体,构造伪干预时间范围是 1976-2000 年,同时估计系数在双边检验和左边检验中在 1% 水平上显著。结合下方的核密度图,可以发现黑色实线代表的真实估计系数在模拟结果的左侧长尾处,表明“基准回归的系数显著为负”这一结果是稳健的。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
. didplacebo did_bbb, treatvar(_intra) pbomix(2) seed(1)

Implementing unrestricted mixed placebo test for staggered DID (version 2) using both fake treatment units and times:
-------------------------------------------------------------------------
The number of units randomly | Th range within which fake
selected as fake treatment units | treatment times are randomly selected
----------------------------------+--------------------------------------
49 | [1976, 2000]
-------------------------------------------------------------------------
Simulations (500):.........10.........20.........30.........40.........50.........60.........70.........80.........90.........100.........110.........120.....
> ....130.........140.........150.........160.........170.........180.........190.........200.........210.........220.........230.........240.........250.....
> ....260.........270.........280.........290.........300.........310.........320.........330.........340.........350.........360.........370.........380.....
> ....390.........400.........410.........420.........430.........440.........450.........460.........470.........480.........490.........500
Results of unrestricted mixed placebo test for staggered DID (version 2) using both fake treatment units and times:
--------------------------------------------------------------
| | P-value
| Coefficient | Two-sided Left-sided right-sided
-----------+-------------+------------------------------------
_intra | -0.017724 | 0.0040 0.0040 0.9960
--------------------------------------------------------------
Note: (1) The two-sided p-value is the frequency that the absolute values of the placebo effects are greater than or equal to the absolute value of
estimated treatment effect.
(2) The left-sided (right-sided) p-value is the frequency that the placebo effects are smaller (greater) than or equal to the estimated treatment
effect.

Finished.

交叠 DID 的混合安慰剂检验图:无约束情形

3.3.2 有约束的混合安慰剂检验

指定 pbomix(3) ​以进行有约束的混合安慰剂检验,结果展示与交叠 DID 的个体安慰剂检验类似。

由于约束了组群不能随机分配,因此不再汇报虚拟的个体数量,构造的伪干预时间范围是 1976-2000 年。在双侧和右侧检验中,估计系数均在 1% 水平上显著,同事黑色实线代表的真实估计系数在模拟结果的左侧长尾处,表明回归系数为负是稳健的。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
. didplacebo did_bbb, treatvar(_intra) pbomix(3) seed(1)

Implementing restricted mixed placebo test for staggered DID (version 3) using both fake treatment units and times:
--------------------------------------
The range within which fake
treatment times are randomly selected
--------------------------------------
[1976, 2000]
--------------------------------------
Simulations (500):.........10.........20.........30.........40.........50.........60.........70.........80.........90.........100.........110.........120.....
> ....130.........140.........150.........160.........170.........180.........190.........200.........210.........220.........230.........240.........250.....
> ....260.........270.........280.........290.........300.........310.........320.........330.........340.........350.........360.........370.........380.....
> ....390.........400.........410.........420.........430.........440.........450.........460.........470.........480.........490.........500
Results of restricted mixed placebo test for staggered DID (version 3) using both fake treatment units and times:
--------------------------------------------------------------
| | P-value
| Coefficient | Two-sided Left-sided right-sided
-----------+-------------+------------------------------------
_intra | -0.017724 | 0.0000 0.0000 1.0000
--------------------------------------------------------------
Note: (1) The two-sided p-value is the frequency that the absolute values of the placebo effects are greater than or equal to the absolute value of
estimated treatment effect.
(2) The left-sided (right-sided) p-value is the frequency that the placebo effects are smaller (greater) than or equal to the estimated treatment
effect.

Finished.

交叠 DID 的混合安慰剂检验图:有约束情形

四、基于 csdid 估计的交叠 DID 的安慰剂检验

1. csdid 估计结果

使用 Callaway and Sant’Anna(2021)开发的 csdid 命令,可以实现进行多个干预时点的 DID 估计。csdid 命令基于 drdid 命令开发,并在后续的绘图中需要使用 coefplot ​命令,这些都是外部命令,在首次使用前需要进行安装。下面是基于 bbb.dta 数据集使用 csdid 命令进行估计的代码。

1
2
3
4
5
6
7
** 安装命令包
ssc install csdid, replace
ssc install drdid, replace
ssc install coefplot, replace

* csdid 估计
csdid log_gini $cov, ivar(statefip) time(wrkyr) gvar(branch_reform) method(dripw) wboot rseed(1) agg(simple)

下面是 csdid ​的估计结果,汇报的 ATT 为 -0.0007548,并且该结果仅在 10% 水平上显著。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
. csdid log_gini $cov, ivar(statefip) time(wrkyr) gvar(branch_reform) method(dripw) wboot rseed(1) agg(simple)
No never treated observations found. Using Not yet treated data
Units always treated found. These will be ignored
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...........xxxxxxxxx
xxxxxxxxxx..........xxxxxxxxxxxxxxxxxxxx...x......
.xxxxxxxxxxxxxxxxxxx..............xxxxxxxxxxxxxxxx
.............xxxxxxxxxxxxxxxxx......xxxxxxxxxxxxxx
xxxxxxxxxxx.x...x...xxxxxxxxxxxxxxxxxxxx..........
.......xxxxxxxxxxxxx................xxxxxxxxxxxxxx
......................xxxxxxxx....................
..xxxxxxxxx..xxxx...x...xxxxxxxxxxxxxxxx..........
.......xxxxxxxxxxxxx.x.xx.xxx.xxxx...xxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Difference-in-difference with Multiple Time Periods

Number of obs = 636
Outcome model : least squares
Treatment model: inverse probability
---------------------------------------------------------------------
| Coefficient Std. err. t [95% conf. interval]
------------+--------------------------------------------------------
ATT | -.0007548 .0085642 -0.09 -.0174154 .0159058
---------------------------------------------------------------------
Control: Not yet Treated

See Callaway and Sant'Anna (2021) for details

2. 交叠 DID 的时间安慰剂检验

首先,来看看使用基于 csdid ​命令估计交叠 DID 的时间安慰剂检验。我们手动生成一个滞后 1 期的干预时间变量,作为伪干预时间用于时间安慰剂检验。使用 if wrkyr < branch_reform 将回归限定在干预前的样本中进行,以进行滞后 1 期的伪干预时间 branch_reform_1 ​的影响。

1
2
gen branch_reform_1 = branch_reform-1
csdid log_gini $cov if wrkyr < branch_reform, ivar(statefip) time(wrkyr) gvar(branch_reform_1) wboot rseed(1) agg(simple)

我们可以发现,结果中 t 值仅为-0.45,并未达到 5% 水平显著性的临界值,同时 95% 置信区间也包括了 0,表明滞后 1 期的伪干预时间的影响不显著,可以认为通过了安慰剂检验。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
. csdid log_gini $cov if wrkyr < branch_reform, ivar(statefip) time(wrkyr) gvar(branch_reform_1) wboot rseed(1) agg(simple)
No never treated observations found. Using Not yet treated data
Units always treated found. These will be ignored
Panel is not balanced
Will use observations with Pair balanced (observed at t0 and t1)
.xxxxxxxxxxxxxxxxxxxxx..xxxxxxxxxxxxxxxxxxxx...xxx
xxxxxxxxxxxxxxxx....xxxxxxxxxxxxxxxxxx.....xxxxxxx
xxxxxxxxxx......xxxxxxxxxxxxxxxxx.x...xxxxxxxxxxxx
xxxx........xxxxxxxxxxxxxx.........xxxxxxxxxxxxx..
........xxxxxxxxxxxx...........xxxxxxxxxxxx..xxxx.
..x.xxxxxxxxxx.............xxxxxxxxx.x.xx.xxx.xxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxx
Difference-in-difference with Multiple Time Periods

Number of obs = 361
Outcome model : least squares
Treatment model: inverse probability
---------------------------------------------------------------------
| Coefficient Std. err. t [95% conf. interval]
------------+--------------------------------------------------------
ATT | -.0060173 .0132436 -0.45 -.0333741 .0213396
---------------------------------------------------------------------
Control: Not yet Treated

See Callaway and Sant'Anna (2021) for details

当然,我们可以使用循环语句,批量做滞后 1-10 期的时间安慰剂检验,参考代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
** 输出表格: 时间安慰剂检验
// 估计滞后1-10期的结果
global K = 10
matrix att_b = J(1,$K,0)
matrix att_V = J($K,$K,0)
forvalues i = 1(1)$K {
cap drop branch_reform_new
qui g branch_reform_new = branch_reform - `i'
qui csdid log_gini $cov if wrkyr < branch_reform, ivar(statefip) time(wrkyr) gvar(branch_reform_new) wboot rseed(1) agg (simple)
matrix att_b[1,`i'] = e(b)[., "ATT"]
matrix att_V[`i',`i'] = e(V)["ATT", "ATT"]
}
mata: st_local("names",invtokens("L":+strofreal(1..$K):+".ATT"))
// 输出为表格展示
matrix colnames att_b = `names'
matrix colnames att_V = `names'
matrix rownames att_V = `names'
ereturn post att_b att_V
ereturn display

上述代码主要包括两个模块,一是估计滞后 1-10 期时间安慰剂检验,并将估计的 ATT 及其方差存储在矩阵 att_b ​和 att_V ​中。二是将矩阵中的结果绘制成表格,然后展示出来。最后得到的结果如下所示。我们可以发现,滞后 1-10 年的估计结果均在 5% 水平上不显著,但滞后 5 年和滞后 10 年在 10% 水平上显著。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
. ereturn display
------------------------------------------------------------------------------
| Coefficient Std. err. z P>|z| [95% conf. interval]
-------------+----------------------------------------------------------------
ATT |
L1. | -.0060173 .0132436 -0.45 0.650 -.0319743 .0199398
L2. | -.0137552 .0191677 -0.72 0.473 -.0513233 .0238128
L3. | -.0033001 .0095432 -0.35 0.729 -.0220045 .0154043
L4. | .0008408 .0113579 0.07 0.941 -.0214203 .0231018
L5. | .0237718 .0130823 1.82 0.069 -.0018691 .0494127
L6. | -.0066938 .014051 -0.48 0.634 -.0342333 .0208456
L7. | .0075708 .0176524 0.43 0.668 -.0270272 .0421688
L8. | -.0013085 .0106612 -0.12 0.902 -.0222041 .0195871
L9. | -.0077957 .0128759 -0.61 0.545 -.033032 .0174405
L10. | .0363283 .0193316 1.88 0.060 -.0015608 .0742175
------------------------------------------------------------------------------

我们也可以使用将上面的结果绘制成带有 95% 置信区间的图,可以更加直观地看到时间安慰剂检验的结果。

交叠 DID 的时间安慰剂检验图

3. 交叠 DID 的个体安慰剂检验

再来看看个体安慰剂检验。didplacebo命令无法检验针对 csdid的结果进行个体安慰剂和混合安慰剂检验,因此这里定义一个 InSpacePlaceboTest ​程序,然后使用 simulate ​命令运行 InSpacePlaceboTest ​程序 500 次,并将估计结果存储到 bbb_InSpacePbo.dta ​数据集中,用于绘制直方图和核密度图。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
** 编写程序
capture drop branch_reform_new
capture program drop InSpacePlaceboTest
program def InSpacePlaceboTest, rclass
preserve
xtshuffle branch_reform, gen(branch_reform_new)
qui csdid log_gini $cov, ivar(statefip) time(wrkyr) gvar(branch_reform_new) agg(simple)
return scalar pbo_eff = _b[ATT]
end

** 调用程序检验:个体安慰剂检验
simulate pbo_eff = r(pbo_eff), seed(1) reps(500): InSpacePlaceboTest
save 数据和代码/tmp_data/bbb_InSpacePbo, replace

** 绘制直方图和核密度图
graph twoway (kdensity pbo_eff) (histogram pbo_eff, fcolor(gs8%50) lcolor(white) lalign(center) below), ///
xline(0, lp(dash)) xline($tr_eff, lp(solid)) xtitle("distribution of placebo effects") ///
ytitle("density") title("In-space Placebo Test") ///
legend(order(1 "Kernel density estimate" 2 "Histogram") rows(1) position(6) region(lstyle(none))) ///
aspect(0.4) name(pbounit, replace)

从下图可以发现,安慰剂效应的平均水平和取值为 0 的黑色竖线(csdid 的估计系数)几乎重合,考虑到其系数为 -0.0007548,且仅在 10% 水平上显著,说明基准回归的结果并不稳健。

交叠 DID 的个体安慰剂检验图

上面的图片中没有用于判别显著性的 p 值,这里仍然使用 500 次自举法得到 ATT 的 pbo_eff ​和真实估计系数 $tr_eff ​进行比较,对其进行描述性统计即可得到个体安慰剂的 p 值。具体来看:

  • 双边检验:是否满足 abs(pbo_eff)>=abs($tr_eff),即是否安慰剂检验 ATT 绝对值大于等于真实估计系数绝对值。
  • 左边检验:是否满足 pbo_eff<=$tr_eff),即是否安慰剂检验 ATT 绝对值小于等于真实估计系数绝对值。
  • 右边检验:是否满足 pbo_eff>=$tr_eff),即是否安慰剂检验 ATT 绝对值大于等于真实估计系数绝对值。

其代码实现如下所示:

1
2
3
4
5
6
7
8
9
// 双边检验
g extreme_abs = (abs(pbo_eff)>=abs($tr_eff))
sum extreme_abs
// 左边检验
g extreme_left = (pbo_eff<=$tr_eff)
sum extreme_left
// 右边检验
g extreme_right = (pbo_eff>=$tr_eff)
sum extreme_right

上面双边检验、左边检验和右边检验的第一步本质是生成了 500 个虚拟变量(因为自举法重复了 500 次)。双边检验、左边检验和右边检验的均值即为显著性水平 p 值,表明不论在哪一个检验中均不显著,表明 csdid 估计系数和安慰剂效应没有显著区别,安慰剂检验未能通过,上面基准回归的结果并不稳健。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// 双边检验
Variable | Obs Mean Std. dev. Min Max
-------------+---------------------------------------------------------
extreme_abs | 500 .956 .2053005 0 1

// 左边检验
Variable | Obs Mean Std. dev. Min Max
-------------+---------------------------------------------------------
extreme_left | 500 .492 .5004367 0 1

// 右边检验
Variable | Obs Mean Std. dev. Min Max
-------------+---------------------------------------------------------
extreme_ri~t | 500 .508 .5004367 0 1

4. 交叠 DID 的混合安慰剂检验

上文已述,didplacebo ​命令无法针对 csdid 的估计结果进行混合安慰剂检验,因此需要手动编写检验程序,并重复运行 500 次。

4.1 无约束的混合安慰剂检验

针对无约束的混合安慰剂检验,设定种群结构可以发生变化。此时编写手动检验程序 MixedPlaceboTest2,并使用 simulate ​命令重复运行 MixedPlaceboTest2 ​程序 500 次,将结果保存在 bbb_MixedPbo2.dta ​数据集中,以方便下面作图和制表。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
** 编写程序: 无约束的混合安慰剂检验
capture program drop MixedPlaceboTest2
prog def MixedPlaceboTest2, rclass
preserve
xtrantreat _intra, method(2) gen(_intra_new)
tofirsttreat _intra_new, gen(branch_reform_new)
qui csdid log_gini $cov, ivar(statefip) time(wrkyr) gvar(branch_reform_new) agg(simple)
return scalar pbo_eff = _b[ATT]
end
** 调用程序检验
simulate pbo_eff = r(pbo_eff), seed(1) reps(500): MixedPlaceboTest2
save 数据和代码/tmp_data/bbb_MixedPbo2, replace

** 绘图
graph twoway (kdensity pbo_eff) (histogram pbo_eff, fcolor(gs8%50) lcolor(white) lalign(center) below), ///
xline(0, lp(dash)) xline($tr_eff, lp(solid)) xtitle("distribution of placebo effect") ///
ytitle("density") title("Unrestricted Mixed Placebo Test") ///
legend(order(1 "Kernel density estimate" 2 "Histo⁃ gram") rows(1) position(6) region(lstyle(none))) ///
aspect(0.4) name(pbomix, replace)

使用 graph twoway 命令绘制无约束混合安慰剂效应的直方图和核密度图,从绘图结果上看,ATT 的取值位于安慰剂效应分布的中部,并非在极端值位置,估计的ATT(黑色实线)与 0 值(黑色虚线)几乎完全重合,表明 ATT 可能和 0 并无显著差异。

交叠 DID 的混合安慰剂检验图:无约束情形

绘图只能查看安慰剂效应的中间情况,不能直观观察到其极端值的分布。因此我们进一步根据真实系数和安慰剂效应的比较,计算无约束混合安慰剂检验的显著性,代码如下所示。

1
2
3
4
5
6
7
8
9
// 双边检验
gen extreme_abs = (abs(pbo_eff)>=abs($tr_eff))
sum extreme_abs
// 左边检验
gen extreme_left = (pbo_eff<=$tr_eff)
sum extreme_left
// 右边检验
gen extreme_right = (pbo_eff>=$tr_eff)
sum extreme_right

结果如下所示,双边检验、左侧检验和右侧检验的均值均超过了 0.1,表明至少在 10% 水平上均未通过无约束混合安慰剂检验,ATT 可能并不显著。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// 双边检验
Variable | Obs Mean Std. dev. Min Max
-------------+---------------------------------------------------------
extreme_abs | 500 .952 .2139803 0 1

// 左边检验
Variable | Obs Mean Std. dev. Min Max
-------------+---------------------------------------------------------
extreme_left | 500 .454 .4983781 0 1

// 右边检验
Variable | Obs Mean Std. dev. Min Max
-------------+---------------------------------------------------------
extreme_ri~t | 500 .546 .4983781 0 1

4.2 有约束的混合安慰剂检验

对于有约束的混合安慰剂检验,其设定是种群结构受到约束不能变化。我们编写检验程序 MixedPlaceboTest3,并使用 simulate ​命令重复运行检验程序 500 次,代码如下所示。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
** 编写程序: 有约束的混合安慰剂检验
capture program drop MixedPlaceboTest3
prog def MixedPlaceboTest3, rclass
preserve
xtrantreat _intra, method(3) gen(_intra_new)
tofirsttreat _intra_new, gen(branch_reform_new)
qui csdid log_gini $cov, ivar(statefip) time(wrkyr) gvar(branch_reform_new) agg(simple)
return scalar pbo_eff = _b[ATT]
end

** 调用程序检验
simulate pbo_eff = r(pbo_eff), seed(1) reps(500): MixedPlaceboTest3
save 数据和代码/tmp_data/bbb_MixedPbo3.dta, replace

** 绘图
graph twoway (kdensity pbo_eff) (histogram pbo_eff, fcolor(gs8%50) lcolor(white) lalign(center) below), ///
xline(0, lp(dash)) xline($tr_eff, lp(solid)) xtitle("distribution of placebo effect") ///
ytitle("density") title("Restricted Mixed Placebo Test") ///
legend(order(1 "Kernel density estimate" 2 "Histo⁃ gram") rows(1) position(6) region(lstyle(none))) ///
aspect(0.4) name(pbomix, replace)

绘图结果如下所示,ATT 的取值位于安慰剂效应分布的中部,并非在极端值位置,估计的ATT(黑色实线)与 0 值(黑色虚线)几乎完全重合,表明 ATT 可能和 0 并无显著差异。

交叠 DID 的混合安慰剂检验图:有约束情形

我们进一步看看双边检验、左边检验和右边检验的结果。

1
2
3
4
5
6
7
8
9
// 双边检验
gen extreme_abs = (abs(pbo_eff)>=abs($tr_eff))
sum extreme_abs
// 左边检验
gen extreme_left = (pbo_eff<=$tr_eff)
sum extreme_left
// 右边检验
gen extreme_right = (pbo_eff>=$tr_eff)
sum extreme_right

基于比较结果生成的虚拟变量均值,即为混合安慰剂效应双边、左边和右边检验的 p 值。从下面的表中可以发现,三个检验值的均值都超过了 0.1,表明至少在 10% 水平上,未能通过有约束的混合安慰剂检验。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// 双边检验
Variable | Obs Mean Std. dev. Min Max
-------------+---------------------------------------------------------
extreme_abs | 500 .966 .1814106 0 1

// 左边检验
Variable | Obs Mean Std. dev. Min Max
-------------+---------------------------------------------------------
extreme_left | 500 .474 .4998236 0 1

// 右边检验
Variable | Obs Mean Std. dev. Min Max
-------------+---------------------------------------------------------
extreme_ri~t | 500 .526 .4998236 0 1

五、写在后面

本文根据陈强等(2025)提供的代码和数据,对标准 DID 和交叠 DID 进行了时间安慰剂、个体安慰剂和混合安慰剂检验。其中交叠 DID 包括有约束和无约束的混合安慰剂检验。针对标准 DID 和使用基于 xtreg ​开发的命令(例如 reghdfe)进行交叠 DID 估计的结果,陈强等(2025)开发的 didplacebo ​命令可以用于安慰剂检验。对于更加常见的使用 csdid ​命令进行交叠 DID 估计的结果,陈强等(2025)也给出了参考的代码用于检验。

当然,DID 系列方法发展迅速,例如放宽样本不允许退出假设的一般 DID、放宽干预行为同质(即存在干预强度差别)的连续 DID、DDD 等方法不断更新,didplacebo 命令不可能服务于所有 DID 类型的安慰剂检验。更加重要的是,参考陈强等对 csdid 命令估计交叠 DID 结果的安慰剂检验思路,设计一个符合自己研究需要的安慰检验代码。