*! version 1.0.2 03jul2026

Copyright

Copyright 2026 Xuanyu Cai and Wenli Xu

Title

diddesign_intro -- Introduction to Double Difference-in-Differences

Introduction

The diddesign package implements the Double Difference-in-Differences
(Double DID) method proposed by Egami and Yamauchi (2023). This method
addresses the question of how researchers can optimally use multiple
pre-treatment periods to improve the DID design.

Multiple pre-treatment periods provide three key benefits:

1. Assessing the parallel trends assumption: Pre-treatment periods enable
placebo tests by applying DID to periods before treatment. The package also
reports equivalence confidence intervals to provide positive evidence for
approximate parallel trends.

2. Improving estimation accuracy: Under the extended parallel trends
assumption, combining multiple DID estimators via GMM increases estimation
accuracy. The Double DID estimator achieves variance no larger than the
standard DID, the sequential DID, or the two-way fixed effects estimator.

3. Allowing for a more flexible parallel trends assumption: The sequential
DID estimator requires only the parallel trends-in-trends assumption, which
permits linear time-varying unmeasured confounding.

The package provides three commands:

diddesign - Main estimation command for Double DID

diddesign_check - Parallel trends assessment and diagnostics

diddesign_plot - Visualization of results

Traditional DID

The traditional Difference-in-Differences (DID) estimator compares changes
in outcomes between treatment and control groups:

tau_DID = (Y_bar_T,post - Y_bar_T,pre) - (Y_bar_C,post - Y_bar_C,pre)

where T denotes the treated group and C denotes the control group.

Assumption 1 (Parallel Trends): The traditional DID estimator requires
that, absent treatment, the outcome trend of the treated group would have been
the same as the outcome trend of the control group. Formally:

E[Y(0)_T,post - Y(0)_T,pre] = E[Y(0)_C,post - Y(0)_C,pre]

This assumption is inherently untestable because it involves counterfactual
outcomes. However, pre-treatment periods can be used to assess its plausibility.

Double DID Method

The Double DID method combines two DID estimators via the generalized method
of moments (GMM) to achieve better properties than either estimator alone.

Assumption 2 (Extended Parallel Trends): This assumption requires that
parallel trends hold for all pairs of adjacent time periods, including
pre-treatment periods. Formally, both of the following conditions hold:

E[Y(0)_T,t=2 - Y(0)_T,t=1] = E[Y(0)_C,t=2 - Y(0)_C,t=1]

E[Y(0)_T,t=1 - Y(0)_T,t=0] = E[Y(0)_C,t=1 - Y(0)_C,t=0]

where t=0,1 are pre-treatment periods and t=2 is the post-treatment period.

Assumption 3 (Parallel Trends-in-Trends): This weaker assumption requires
only that the change in outcome trends is the same across treatment and
control groups. Formally:

[E[Y(0)_T,t=2 - Y(0)_T,t=1] - E[Y(0)_T,t=1 - Y(0)_T,t=0]]

= [E[Y(0)_C,t=2 - Y(0)_C,t=1] - E[Y(0)_C,t=1 - Y(0)_C,t=0]]

This assumption permits linear time-varying unmeasured confounding, where
unobserved confounding increases or decreases over time at a constant rate.

Relationship between assumptions: The extended parallel trends assumption
(Assumption 2) implies both the standard parallel trends assumption (Assumption
1) and the parallel trends-in-trends assumption (Assumption 3). However,
Assumptions 1 and 3 are logically independent; neither implies the other.

The sequential DID estimator: The sequential DID (sDID) estimator
subtracts the earlier pre-treatment DID from the standard DID in the
default lead(0) case:

tau_sDID = DID(t=2,t=1) - DID(t=1,t=0)

where DID(t1,t2) denotes the standard DID using periods t1 and t2. The sDID
estimator is consistent under Assumption 3 (parallel trends-in-trends).
When lead()>0 is requested in diddesign, the command instead uses
the lead-specific dynamic extension from Appendix E, anchored at the last
pre-treatment period rather than the adjacent post-treatment difference shown
above. See diddesign for the runtime lead() contract and Appendix E
for the generalized k-th order difference definition.

The Double DID estimator: The Double DID optimally combines the standard
DID and sequential DID estimators using GMM:

tau_dDID = w1 x tau_DID + w2 x tau_sDID

where w1 + w2 = 1, and the weights are chosen to minimize asymptotic variance:

w1 = [Var(tau_sDID) - Cov(tau_DID,tau_sDID)] / [Var(tau_DID) + Var(tau_sDID) - 2 x Cov(tau_DID,tau_sDID)]

Under the extended parallel trends assumption, the Double DID achieves variance
no larger than any of its component estimators. When only parallel
trends-in-trends holds, the Double DID converges to the sequential DID.

Generalized K-DID: When more than two pre-treatment periods are available,
the kmax() option enables the generalized K-DID estimator (Appendix E of
the paper). The k-th component estimator uses a k-th order difference operator
that can account for (k-1)-th degree polynomial time-varying confounding. The
K-DID combines K component estimators via the same GMM framework. Optional
J-test moment selection (jtest(on)) uses Hansen's overidentification test
to adaptively drop potentially violated moment conditions.

Staggered Adoption Design

In many settings, different units receive treatment at different times. This
is called staggered adoption (SA) or staggered treatment timing.

Key features of SA designs:

- Multiple treatment timing groups (cohorts)

- Not-yet-treated units serve as controls for newly-treated units

- Treatment effects are aggregated using time weights

The SA-Double-DID estimator computes:

tau_SA = Sum_t pi_t x tau_t

where pi_t is the proportion of units treated at time t, and tau_t is the
cohort-specific Double DID estimate.

The treatment timing matrix (Gmat):

The package uses a treatment timing matrix to track each unit's treatment
status over time:

0 = control or not-yet-treated

1 = first treatment period (treatment onset)

-1 = post-treatment (already treated in previous periods)

Parallel trends assessment

Placebo tests:

The diddesign_check command applies DID estimation to pre-treatment
periods only. If parallel trends hold, these placebo estimates should be
close to zero.

Limitations of traditional hypothesis testing:

A common practice is to test H0: pre-trend = 0 and interpret non-rejection
as evidence for parallel trends. However, this reasoning is flawed. Failing
to reject the null may occur either because trends are truly parallel or
because the test lacks statistical power (e.g., small sample size).

Equivalence testing:

Equivalence testing addresses this limitation by reversing the hypotheses:

H0: |pre-trend| >= delta (pre-trends are large)

H1: |pre-trend| < delta (pre-trends are small, within equivalence bound delta)

Rejecting H0 provides positive evidence that pre-trends are small, rather
than merely reflecting low statistical power.

Interpreting the 95% standardized equivalence CI:

The command reports the 95% standardized equivalence confidence interval,
which indicates the smallest delta for which equivalence can be established.
This interval is expressed in units of the baseline control group standard
deviation.

- Narrower intervals provide stronger evidence for parallel trends

- Substantive interpretation should consider domain knowledge about what
constitutes a meaningful deviation

Recommended workflow

Step 1: Assess parallel trends

Use diddesign_check to perform placebo tests on pre-treatment periods.
Specify the outcome variable, treatment indicator, unit identifier, and time
variable. Multiple lag periods can be tested to assess parallel trends across
different pre-treatment intervals. Examine the equivalence confidence intervals;
smaller intervals provide stronger support for the parallel trends assumption.

Step 2: Visualize diagnostics

Use diddesign_plot to generate diagnostic visualizations after running
diddesign_check. The trends plot displays outcome trajectories for
treatment and control groups, allowing visual inspection of whether groups
follow similar patterns before treatment. The placebo plot shows equivalence
confidence intervals centered around zero, with bounds indicating the magnitude
of potential pre-trends.

Step 3: Estimate treatment effects

If diagnostics are satisfactory, use diddesign to estimate treatment
effects. The command computes the Double DID estimator, which optimally
combines DID and sequential DID (sDID) using GMM weights. For staggered
adoption designs, specify design(sa) to account for multiple treatment
timing groups.

Step 4: Report results

In publications, report both the diagnostic results (Steps 1-2) and the
main estimates (Step 3). Key elements to include:

- Equivalence CI bounds and the threshold used for assessment

- Trends plot showing pre-treatment patterns for both groups

- Double DID estimate with standard error and confidence interval

- GMM weights indicating the contribution of DID and sDID components

References

Egami, N. and S. Yamauchi. 2023.
Using Multiple Pretreatment Periods to Improve Difference-in-Differences
and Staggered Adoption Designs.
Political Analysis 31(2): 195-212.
https://doi.org/10.1017/pan.2022.8

Author

Xuanyu Cai

City University of Macau

xuanyuCAI@outlook.com

Wenli Xu

City University of Macau

wlxu@cityu.edu.mo

Also see

Online: diddesign, diddesign_check, diddesign_plot, diddesign_intro