Regression-based multi-period difference-in-differences with heterogenous treatment effects
Author JuliaDiffinDiffs
3 Stars
Updated Last
2 Years Ago
Started In
August 2020


Regression-based multi-period difference-in-differences with heterogenous treatment effects

CI-stable codecov

This package provides a collection of regression-based estimators and auxiliary tools for difference-in-differences (DID) across multiple treatment groups over multiple time periods. It is a component of DiffinDiffs.jl that can also be used as a standalone package.


The development of this package is not fully complete. New features and improvements are being added over time.

Applicable Environment

The baseline empirical environment this package focuses on is the same as the one considered by Sun and Abraham (2020):

  • Treatment states are binary, irreversible and sharp.
  • Units may receive treatment in different periods in a staggered fashion.
  • Treatment effects may evolve over time following possibly heterogenous paths across treated groups.

The parameters of interest include:

  • A collection of average treatment effects on each group of treated units in different periods.
  • Interpretable aggregations of these group-time-level parameters.

Main Features

This package is developed with dedication to both the credibility of econometric methodology and high performance for working with relatively large datasets.

The main features are the following:

  • Automatic and efficient generation of indicator variables based on empirical design and data coverage.
  • Enforcement of an overlap condition based on the parallel trends assumption.
  • Fast residualization of regressors from fixed effects via FixedEffects.jl.
  • Interaction-weighted DID estimators proposed by Sun and Abraham (2020).
  • Cell-level decomposition of coefficient estimates for analytical reconciliation across specifications.

As a component of DiffinDiffs.jl, it follows the same programming interface shared by all component packages. In particular, it is benefited from the macros @did and @specset that largely simplify the construction of groups of related specifications and reduce unnecessary repetitions of identical intermediate steps (e.g., partialling out fixed effects for the same regressors). Tools for easing the export of estimation results are also being developed.

Econometric Foundations

The package does not enforce the use of a specific estimation procedure and allows some flexibility from the users. However, it is mainly designed to ease the adoption of recent advances in the difference-in-differences literature that overcome certain pitfalls that may arise in scenarios where the treated units get treated in different periods (i.e., the staggered adoption design).

The development of this package is directly based on the following studies:

Some other studies are also relevant and have provided inspiration:


Borusyak, Kirill, and Xavier Jaravel. 2018. "Revisiting Event Study Designs with an Application to the Estimation of the Marginal Propensity to Consume." Unpublished.

Callaway, Brantly, and Pedro H. C. Sant'Anna. 2020. "Difference-in-Differences with Multiple Time Periods." Journal of Econometrics, forthcoming.

de Chaisemartin, Clément, and Xavier D'Haultfœuille. 2020. "Two-Way Fixed Effects Estimators with Heterogeneous Treatment Effects." American Economic Review 110 (9): 2964-96.

Goodman-Bacon, Andrew. 2020. "Difference-in-Differences with Variation in Treatment Timing." Unpublished.

Sun, Liyang, and Sarah Abraham. 2020. "Estimating Dynamic Treatment Effects in Event Studies with Heterogeneous Treatment Effects." Journal of Econometrics, forthcoming.

Used By Packages

No packages found.