Skip to content

DRDID

1.4.0Package record

Doubly Robust Difference-in-Differences Estimators

2packages depend
118.8Kdownloads / year
97.1%test coverage
13/13flavors OK

Overview

About

Implements the locally efficient doubly robust difference-in-differences (DiD) estimators for the average treatment effect proposed by Sant'Anna and Zhao (2020) doi:10.1016/j.jeconom.2020.06.003. The estimator combines inverse probability weighting and outcome regression estimators (also implemented in the package) to form estimators with more attractive statistical properties. Two different estimation methods can be used to estimate the nuisance functions.

Changes in 1.4.0
  • Panel preprocessing now excludes whole units with missing covariates or sampling weights before checking time invariance. Retained units remain matched by ID, and observed time-varying covariates or weights still fail.
  • Formula-based estimators preserve user columns named y, D, post, or w when extracting outcomes, weights, and covariates. Renaming a variable no longer changes its meaning through internal preprocessing columns.
  • Improved DR estimators now require a numerically verified solution of the original exponential-IPT equations. Logit MLE is used only for initialization; failed IPT fits stop and suggest explicitly rerunning the traditional DR estimator. The secondary IPT candidate is checked against the original equations even when its continued objective reports convergence. The returned ps.flag identifies the verified fitting route (0 or 1); value 2 is removed. Fitting normalizes the common scale of weights to avoid scale-dependent optimizer stopping. Numerically ill-conditioned designs are rejected. Every weighted-bootstrap replicate must pass the same check, and failures stop with the replicate number without skipping or redrawing the fit.
Show all changes in 1.4.0Hide the rest of the changes in 1.4.0
  • The weighted bootstrap in drdid_imp_panel() now uses the point estimator's treated-weight denominator for its combined residual contributions. This makes each draw refit the same implemented statistic, including active trimming and supplied designs without an intercept. Weighted-bootstrap draws, standard errors, and intervals can change; point estimates, analytic inference, and multiplier inference are unchanged.
  • IPT criteria now evaluate weighted nonlinear contributions without first creating avoidable overflowing or underflowing intermediate exponentials. Weighted values, gradients, and Hessians retain representable terms and reject unresolved opposing overflow terms. The original criteria and continuation rule are preserved. Fitting reuses fixed-data checks and avoids unnecessary exceptional arithmetic while retaining these safeguards.
  • Zero-weight rows no longer enter IPT objective, gradient, or Hessian arithmetic. Extreme finite covariates in those rows cannot create NaNs through zero times an overflowing intermediate value. The original objective divisor, model dimension, and secondary continuation threshold are preserved.
  • The IPT propensity-score fallback used by the improved DR estimators now weights its full objective consistently with its gradient and Hessian. This corrects optimization with unequal observation or bootstrap weights when the primary trust fit does not converge.
  • Sampling weights are checked before normalization; negative, nonfinite, all-zero, or incorrectly sized low-level weights now give a clear error. Legitimate zero weights and existing missing-data exclusion are preserved.
  • The weighted bootstrap in ipw_did_rc() now refits the same statistic as the point estimator, including normalization of the combined observation and bootstrap weights and the full-sample pre/post time shares. Trimming affects comparison contributions, as in the point estimator. Weighted bootstrap draws, standard errors, and intervals can change; the original ATT, analytic inference, and multiplier bootstrap are unchanged.
  • ipw_did_rc() now includes the effect of sample-mean normalization of observation weights in its influence function and the resulting analytic and multiplier-bootstrap inference under iid sampling. The ATT point estimate is unchanged.
  • Bootstrap inference now returns a zero standard error and point interval when every centered bootstrap draw is exactly zero. Nonfinite draws or a zero IQR with nonzero draws stop with a clear error; no draws are removed or redrawn, and positive-scale inference retains its existing arithmetic.
  • twfe_did_panel() and twfe_did_rc() now preserve matrix dimensions when removing a supplied intercept. An intercept plus one covariate now fits the same regression as supplying that covariate as a numeric vector or a matrix with one column, instead of failing. Intercept-only inputs retain their existing no-covariate behavior.
  • twfe_did_panel() now accounts for dependence between each individual's pre/post observations in its analytical standard error. With covariates, the returned influence function now has one value per individual instead of one per period row. This matches individual-clustered sandwich inference without small-sample corrections and the other panel estimators' convention. The point estimate and both bootstrap procedures are preserved, up to floating-point precision. The no-covariate inference path is unchanged. Direct calls now reject missing or mismatched individual inputs before fitting, preventing row omission from breaking pre/post alignment.
  • Bootstrap estimation now rejects nboot values that are not finite scalar integers of at least 2 before fitting or drawing bootstrap weights. The low-level NULL default remains 999; boot = FALSE continues to ignore it.
  • Panel preprocessing for drdid(), ordid(), and ipwdid() now removes both observations of a unit when either outcome is missing, matches pre/post outcomes by individual ID, and checks group sizes after exclusions. Previously, dropping individual rows with missing outcomes could silently pair different individuals and produce incorrect point estimates and standard errors. Warnings now report the number of affected panel units.
  • drdid_rc() and drdid_rc1(): the estimation effect of the pre-period outcome regression for the comparison group now enters the influence function with the sign given in Appendix B of Sant'Anna and Zhao (2020). It previously entered with the opposite sign. Point estimates are unchanged. Analytic and multiplier-bootstrap standard errors change. The two versions agree asymptotically when the propensity score model is correctly specified, but not when only the outcome regressions are.
  • Treatment indicators must use 0 for comparison and 1 for treated units. Invalid coding is rejected explicitly rather than silently changing weights.
  • The internal GLM fitter now rejects designs with fewer rows than columns before entering fastglm. Such designs cannot have full column rank. Callers receive an ordinary R error when a regression cell is undersized; supported fits retain the same calculations.

From NEWS.md in the release

Install

Health

CRAN checks
13OK
Slowest check: 3.3 min · r-devel-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 4 earlier changesHide 4 earlier changes
  • ERROR11 OK, 1 ERROR2026-04-25
  • OK14 OK2026-04-22
  • ERROR13 OK, 1 ERROR2026-04-18
  • OK14 OK2026-03-10
Advisories

none known

Documentation

In release 1.4.0
READMEYes · 253 wordsVignettesNoNEWSYes · 100% structured · mentions 1.4.0Citation fileYes · cites a publicationWebsiteYes · pkgdown
Help pages
21 (1 internal)includes a package overview page
Examples that run
100%17 run in a plain check
Exported functions with examples
100%
Documented parameters
100%
Return-value docs
100%
Help pages citing references
86%

Downloads

118.8K
CRAN downloads in the past year
Rank #1,184 · ~326/day · ~9.9K/mo
Daily download trend is not available in this view yet.
11.1K30 days
28.6K90 days
118.8K1 year
Compare downloads with other packages →
Also on1.3K r2u3 autocran3.6K conda_forge78 c2d4u

Repository

104Stars
45Forks
4Open issues
0Open PRs
10Releases
227Commits
5Commit identities
227 commits · Last activity 2026-10-22 · +1% stars, 30d
Responsiveness
How these are sampled
PRs merged (all time)
100%
Median days to close, 50 most recently updated closed issues
350
Median days to close, 50 most recently updated closed PRs
0

Stars over time

2025-07-21 · 932026-10-13 · 104
PracticesBeta

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

Checks run against github.com/pedrohcgs/drdid on 2026-10-21.

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)
pkgdown

GitHub Pages site last deployed 2026-10-21 · The repository has a site deploy workflow

pkgdown site last built 2026-10-21, before release 1.4.0 (2026-10-22)

Coverage (1)
Coverage reporting (Codecov)
Reproducibility and dev environment (1)
data-raw/
Show all practicesHide 2 practices
CRAN release process (2)
cran-comments.mdCRAN-SUBMISSION
Lint, format, editor (1)
RStudio project
How this is detected·Detection ruleset v4 (2026-10-20)
AI coding toolsBeta

This repository shows signs of AI coding tools.

  • Claude Codefirst seen 2026-05-25
    Commits: at least 1 crediting it in the message
From outside contributors
  • Claude Code
    Pull requests: 1 from outside contributors, first on 2026-05-25, 1 from forks
Models named in its commits
  • Claude Sonnet 4.61 commit · May 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
9 external dependencies (excludes base and recommended)

Installing DRDID adds 12 packages (8 with compiled code, 26 MB of source tarballs). Heaviest: BH 14 MB, data.table 5.7 MB, Rcpp 1.8 MB.

Depends (1)
R >= 3.5
LinkingTo (1)
Enhances (0)
none
Reverse dependencies
2direct
6indirect
Imports 2
Depends, Imports or LinkingTo, most downloaded first

Datasets

People & History

People (2)
Author, Maintainer since 1.0.0 (2020), Copyright holder
Author · added in 1.0.1
Listed in earlier versions (1)
Jun B. Zhao
no longer listed · 1.0.0
Releases (12)

Pick two releases to compare their code metrics.

  • 1.4.0Latest
    record
    2026-06-10 · current release · diff ↗
  • 1.3.0
    record
    2026-06-10 · diff ↗
  • R
    R 4.6.0 released · 2026-04-24
  • 1.2.3
    record
    2025-12-04 · diff ↗
  • 1.2.2
    record
    2025-05-30 · diff ↗
  • R
    R 4.5.0 released · 2025-04-11
  • 1.2.0
    record
    2024-10-07 · diff ↗
  • 1.1.0
    record
    2024-09-05 · diff ↗
  • 1.0.7
    record
    2024-07-06 · diff ↗
  • R
    R 4.4.0 released · 2024-04-24
  • 1.0.6
    record
    2023-05-18 · diff ↗
  • R
    R 4.3.0 released · 2023-04-21
  • unarchivedReturned to CRAN
    2022-07-19
  • 1.0.4
    record
    2022-07-19 · diff ↗
  • archivedRemoved from CRAN
    2022-07-09
    requires archived package 'BMisc'
  • R
    R 4.2.0 released · 2022-04-22
Show 5 earlier eventsHide 5 earlier events
  • 1.0.3
    record
    2021-11-13 · diff ↗
  • R
    R 4.1.0 released · 2021-05-18
  • 1.0.1
    record
    2021-01-07 · diff ↗
  • 1.0.0
    record
    2020-05-18
  • R
    R 4.0.0 released · 2020-04-24

Package metadata

First published
2020-05-18
Total releases
12 / 6 yrs
License
GPL-3 OSI
Minimum R
≥ 3.5
Bundled data
401 KB / 3 files
Download size
534 KB
Appears in task views

Cite

Cite this package

Run in R for the authors' entry:

citation("DRDID")

The package provides a citation file, so citation() returns the authors' own entry.

It points to 10.1016/j.jeconom.2020.06.003.

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 DRDID version 1.4.0 [Data set]. HJJB, LLC. Data release v2026-10-23. https://doi.org/10.5281/zenodo.21843040

From data release v2026-10-23, 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