Package: did 2.5.1

did: Treatment Effects with Multiple Periods and Groups

The standard Difference-in-Differences (DID) setup involves two periods and two groups -- a treated group and untreated group. Many applications of DID methods involve more than two periods and have individuals that are treated at different points in time. This package contains tools for computing average treatment effect parameters in Difference in Differences setups with more than two periods and with variation in treatment timing using the methods developed in Callaway and Sant'Anna (2021) <doi:10.1016/j.jeconom.2020.12.001>. The main parameters are group-time average treatment effects which are the average treatment effect for a particular group at a particular time. These can be aggregated into a fewer number of treatment effect parameters, and the package deals with the cases where there is selective treatment timing, dynamic treatment effects, calendar time effects, or combinations of these. There are also functions for testing the Difference in Differences assumption, and plotting group-time average treatment effects.

Authors:Brantly Callaway [aut, cre], Pedro H. C. Sant'Anna [aut]

did_2.5.1.tar.gz
did_2.5.1.zip(r-4.7)did_2.5.1.zip(r-4.6)did_2.5.1.zip(r-4.5)
did_2.5.1.tgz(r-4.6-any)did_2.5.1.tgz(r-4.5-any)
did_2.5.1.tar.gz(r-4.7-any)did_2.5.1.tar.gz(r-4.6-any)
did_2.5.1.tgz(r-4.6-emscripten)
manual.pdf |manual.html
DESCRIPTION |NEWS
card.svg |card.png
did/json (API)

# Install 'did' in R:
install.packages('did', repos = c('https://bcallaway11.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/bcallaway11/did/issues

Pkgdown/docs site:https://bcallaway11.github.io

Datasets:
  • mpdta - County Teen Employment Dataset

On CRAN:

Conda:

13.50 score 405 stars 4 packages 1.9k scripts 14k downloads 25 exports 47 dependencies

Last updated from:9aba07d054. Checks:9 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-x86_64OK521
source / vignettesOK247
linux-release-x86_64OK529
macos-release-arm64OK431
macos-oldrel-arm64OK295
windows-develOK573
windows-releaseOK624
windows-oldrelOK598
wasm-releaseOK139

Exports:aggteAGGTEobjatt_gtbuild_sim_datasetcompute.aggtecompute.att_gtcompute.att_gt2conditional_did_pretestDIDparamsggdidglancegplotindicatormbootMPMP.TESTpre_process_didpre_process_did2process_attgtreset.simsimsplottest.mboottidytrimmer

Dependencies:BHbigmemorybigmemory.sriBMiscclicpp11data.tabledplyrDRDIDdreamerrfarverfastglmFormulagenericsggplot2gluegtableisobandlabelinglatticelifecyclemagrittrMatrixpbapplypillarpkgconfigpurrrR6RColorBrewerRcppRcppArmadilloRcppEigenrlangS7scalesstringistringmagicstringrtibbletidyrtidyselecttrustutf8uuidvctrsviridisLitewithr

Getting Started with the did Package
Introduction | Examples with simulated data | Estimating Group-Time Average Treatment Effects | Other features of the did package | Adjustments for Multiple Hypothesis Testing | Aggregating group-time average treatment effects | Simple Aggregation | Dynamic Effects and Event Studies | Group-Specific Effects | Calendar Time Effects | Small Group Sizes | Selecting Alternative Control Groups | Repeated cross sections | Unbalanced Panel Data | Alternative Estimation Methods | An example with real data | The Effect of the Minimum Wage on Youth Employment | Common Issues with the did package | Bugs

Last update: 2026-06-13
Started: 2019-03-27

Introduction to DiD with Multiple Time Periods
Introduction | Background | DiD with 2 Periods and 2 Groups | Two way fixed effects regressions | Treatment Effects in Difference in Differences Designs with Multiple Periods | Main Assumptions | Group-Time Average Treatment Effects | Parallel Trends Conditional on Covariates | Aggregating Group-Time Average Treatment Effects | Conclusion | References

Last update: 2026-06-10
Started: 2020-03-31

Problems with two-way fixed-effects event-study regressions
Introduction | Setup with all units being eventually treated and homogeneous treatment effect dynamics | Visualizing the DGP | Estimating dynamic treatment effects via TWFE event-study regressions | Using the Callaway and Sant'Anna (2021) framework | Setup with a group that remains untreated at the end of the sample | DGP with a "never-treated" group and homogeneous treatment effect dynamics | Setup with Heterogeneous Treatment Effects | Conclusion | References

Last update: 2026-06-10
Started: 2021-01-14

Pre-Testing in a DiD Setup using the did Package
Introduction | Common Approaches to Pre-Testing in Applications | Pitfalls with Event Study Regressions | Best Case Scenario for Pre-Testing | Pitfall: Selective Treatment Timing | Conditional Moment Tests | References

Last update: 2026-03-02
Started: 2020-03-31

Writing Extensions to the did Package
Introduction | DiD with Anticipation | Computing Treatment Effects under DiD with Anticipation | Conclusion

Last update: 2020-12-08
Started: 2020-07-21