Skip to content

Treatment Effects with Multiple Periods and Groups

3packages dependsuggested by 11
131.4Kdownloads / year
93.4%test coverage
13/13flavors OK

Overview

About

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.

Changes in 2.5.1
  • Bug fix (att_gt()): with control_group = "notyettreated" and no never-treated group, the presence of already-treated units (treated in or before the first period, possibly via anticipation) no longer affects the ATT(g,t) of the other groups. The last-treated cohort, which serves as the not-yet-treated comparison group in this design, was being deleted from the data along with the always-treated units — biasing the remaining estimates or turning them into NA — and is now retained. control_group = "nevertreated" was unaffected.
  • Bug fix (fix_weights = "varying" standard errors): on a *balanced* panel, fix_weights = "varying" reported standard errors (analytic and bootstrap, and all aggte() aggregations) that were exactly **2× too large**. Point estimates were correct. The repeated-cross-section influence function is normalized over the 2·n_units stacked observations; folding the pre- and post-period halves to the unit level was missing the corresponding 1/2. Fixed in both code paths; verified against a Monte Carlo (the corrected SE now matches the empirical sampling standard deviation, and equals the panel-estimator SE when weights are time-invariant). Repeated cross sections and unbalanced panels were unaffected.
  • aggte() now fails gracefully instead of with cryptic errors when an aggregation has an empty or all-NA selection: type = "calendar" with na.rm = TRUE drops calendar periods whose post-treatment cells are all NA (analogous to the existing type = "group" guard) rather than erroring; and type = "simple"/"dynamic" with a min_e/max_e window that excludes every post-treatment period now return a clear message instead of an internal "report this as a bug"/"non-numeric argument" error.
  • att_gt() now rejects a negative gname up front with a clear message in both faster_mode = TRUE and FALSE. Previously negative cohort codes (out of spec — gname must be 0 for never-treated or a positive treatment time) were silently accepted on the fast path but errored on the slow path.
  • The parallel multiplier bootstrap (bstrap = TRUE, pl = TRUE, cores > 1, when the influence function has more than 2500 rows — i.e. more than 2500 units, or more than 2500 clusters when clustered standard errors are used) is now reproducible under a fixed set.seed(). It previously used the default Mersenne-Twister RNG inside parallel::mclapply(), whose forked workers re-seed non-deterministically, so bootstrap standard errors and uniform-band critical values drifted between identical-seed runs. It now uses L'Ecuyer-CMRG parallel RNG streams (and restores the caller's RNG kind on exit). Point estimates were always unaffected.
  • Fixed a crash in the parallel bootstrap when biters < cores (with pl = TRUE, cores > 1, and more than 2500 influence-function rows — units, or clusters under clustered inference): the per-core work split could produce a negative chunk size. The split is now always non-negative.
  • aggte(type = "calendar") now warns when min_e, max_e, or balance_e is supplied, since these event-study options do not apply to calendar-time aggregation (the unrestricted, correct calendar effects are returned, as before).

From NEWS.md in the release

Install

Health

CRAN checks
13OK
Slowest check: 12.4 min · r-oldrel-windows-x86_64
Status changes
  • OK13 OK2026-08-05
  • NOTE12 OK, 1 NOTE2026-08-01
  • OK13 OK2026-06-09
  • ERROR12 OK, 1 ERROR2026-06-08
  • OK13 OK2026-05-02
Show 2 earlier changesHide 2 earlier changes
  • ERROR11 OK, 1 ERROR2026-04-25
  • OK14 OK2026-03-10
Advisories

none known

Documentation

In release 2.5.1
READMEYes · 1,035 wordsVignettesYes · 5 · dynamicNEWSYes · 100% structured · mentions 2.5.1Citation fileYes · cites a publicationWebsiteYes · pkgdown
Help pages
44 (12 internal)includes a package overview page
Examples that run
33%1 run in a plain check · 2 never run
Exported functions with examples
13%
Documented parameters
91%
Return-value docs
83%
Help pages citing references
5%

Downloads

131.4K
CRAN downloads in the past year
Rank #1,158 · ~360/day · ~10.9K/mo
Daily download trend is not available in this view yet.
11.6K30 days
29.7K90 days
131.4K1 year
Compare downloads with other packages →
Also on988 r2u9 autocran2.6K conda_forge84 c2d4u

Repository

422Stars
133Forks
4Open issues
3Open PRs
7Releases
733Commits
13Commit identities
733 commits · Last activity 2026-08-28 · +0.7% stars, 30d · Default branch at 2.5.1.902, ahead of CRAN 2.5.1 (checked 2026-10-18) · Discussions: 13 posts
Responsiveness
How these are sampled
PRs merged (all time)
74%
Median days to close, 50 most recently updated closed issues
757
Median days to close, 50 most recently updated closed PRs
0

Stars over time

2025-10-09 · 3592026-10-07 · 422
PracticesBeta

10 development-tooling and community-health practices detected across 6 families in the upstream repository

Checks run against github.com/bcallaway11/did on 2026-10-18.

Continuous integration (2)
GitHub ActionsR CMD check workflow

The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel

Docs source (3)
README.Rmdpkgdown

GitHub Pages site last deployed 2026-08-28

pkgdown site last built 2026-07-30

Coverage (1)
Coverage reporting (Codecov)
CRAN release process (1)
cran-comments.md
Show all practicesHide 2 practices
Research and citation (1)
CITATION.cff
Lint, format, editor (2)
lintrRStudio project
How this is detected·Detection ruleset v3 (2026-09-26)
AI coding toolsBeta

This repository shows signs of AI coding tools.

  • Claude Codefirst seen 2025-11-08
    Named in .Rbuildignore: .claude, CLAUDE.md
    Named in .gitignore: .claude, CLAUDE.md
    Pull request it wrote: opened by a project member
    Commits: at least 16 crediting it in the message
  • GitHub Copilotfirst seen 2026-03-01
    Pull request: opened by its own account
Models named in its commits
  • Claude Sonnet 4.610 commits · Jun 2026
  • Claude Opus 4.65 commits · Apr 2026
  • Claude Sonnet 51 commit · Jul 2026
Counts are commits, not lines of code. Commits by a tool's accounts count once across all of its accounts. Commits crediting it are the largest count among its credit lines, a minimum.How this is detected·Detection ruleset v4 (updated 2026-09-27)

Dependencies

Declared dependencies
20 external dependencies (excludes base and recommended)

Installing did adds 45 packages (25 with compiled code, 59 MB of source tarballs). Heaviest: BH 14 MB, stringi 11 MB, ggplot2 6.0 MB.

Depends (1)
R >= 4.1.0
LinkingTo (0)
none
Enhances (0)
none
Reverse dependencies
3direct
0indirect
Imports 3
Suggested by 11
Show all 14 packagesHide all 14 packages
Depends, Imports or LinkingTo, most downloaded first
Suggests, most downloaded first

Datasets

People & History

People (2)
Author, Maintainer since 1.0.0 (2018)
Author · added in 2.0.0
Listed in earlier versions (1)
Pedro H.C. Sant\'Anna
no longer listed · 1.0.0 to 1.2.3
Releases (14)

Pick two releases to compare their code metrics.

  • 2.5.1Latest
    record
    2026-07-08 · current release · diff ↗
  • 2.5.0
    record
    2026-06-13 · diff ↗
  • R
    R 4.6.0 released · 2026-04-24
  • 2.3.0
    record
    2025-12-13 · diff ↗ ·
    added 2 exports
    compute.att_gt2, pre_process_did2
  • R
    R 4.5.0 released · 2025-04-11
  • R
    R 4.4.0 released · 2024-04-24
  • R
    R 4.3.0 released · 2023-04-21
  • unarchivedReturned to CRAN
    2022-07-20
  • 2.1.2
    record
    2022-07-20 · diff ↗
  • archivedRemoved from CRAN
    2022-07-09
    requires archived package 'BMisc'
  • R
    R 4.2.0 released · 2022-04-22
  • 2.1.1
    record
    2022-01-27 · diff ↗
  • 2.1.0
    record
    2021-12-10 · diff ↗ ·
    removed 2 exports
    mp.spatt, mp.spatt.test
    added 6 exports
    build_sim_dataset, glance, reset.sim, sim, tidy, trimmer
  • R
    R 4.1.0 released · 2021-05-18
  • 2.0.0
    record
    2020-12-11 · diff ↗ ·
    removed 3 exports
    compute.mp.spatt, expf, onefun
    added 11 exports
    AGGTEobj, DIDparams, aggte, att_gt, compute.att_gt, conditional_did_pretest, mboot, pre_process_did, process_attgt, splot, test.mboot
  • R
    R 4.0.0 released · 2020-04-24
Show 14 earlier eventsHide 14 earlier events
  • unarchivedReturned to CRAN
    2020-02-18
  • 1.2.3
    record
    2020-02-18 · diff ↗
  • archivedRemoved from CRAN
    2020-02-16
    check problems were not corrected in time
  • 1.2.2
    record
    2019-06-21 · diff ↗
  • 1.2.1
    record
    2019-06-14 · diff ↗
  • R
    R 3.6.0 released · 2019-04-26
  • 1.2.0
    record
    2018-10-17 · diff ↗
  • unarchivedReturned to CRAN
    2018-09-11
  • 1.1.2
    record
    2018-09-11 · diff ↗
  • archivedRemoved from CRAN
    2018-08-19
    check problems were not corrected despite reminders
  • 1.1.0
    record
    2018-07-11 · diff ↗
  • R
    R 3.5.0 released · 2018-04-23
  • 1.0.0
    record
    2018-04-03
  • R
    R 3.4.0 released · 2017-04-21

Package metadata

First published
2018-04-03
Total releases
14 / 8 yrs
License
GPL-3 OSI
Minimum R
≥ 4.1.0
Bundled data
28 KB / 1 file
Download size
4.5 MB
Appears in task views

Cite

Cite this package

Run in R for the authors' preferred citation:

citation("did")

The package provides a citation file that builds its entry when R runs it. Run citation() to see it.

The repository also keeps a CITATION.cff.

Cite the R Observatory

For a number measured here: a download total, a coverage figure, an archival date.

APA

Balamuta, J. J. (2026). R Observatory: Metrics for did version 2.5.1 [Data set]. HJJB, LLC. Data release v2026-10-20. https://doi.org/10.5281/zenodo.21843040

From data release v2026-10-20, which the citation names so these numbers can be found later. More on citing and the projects behind them.

Report a problem with this page →

Privacy choices

These apply to this browser and are stored on this device only. Nothing about your choice is sent to us.

Read the privacy policy