cdid — Difference-in-differences with incomplete panels
On this page
cdid brings widely used difference-in-differences estimators into a common framework for complete and incomplete panels. It reproduces documented specifications of established methods and extends them with chained comparisons, observation weighting, change imputation and doubly robust corrections for selective missingness, by leveraging the chained difference-in-differences (chained DiD).
The foundational paper is The Chained Difference-in-Differences by Christophe Bellégo, David Benatia and Vincent Dortet-Bernadet, published in the Journal of Econometrics. It explicitly formalizes missing-trends assumptions and establishes identification, estimation and inference using overlapping incomplete panels, with conditional extensions for selection on observed characteristics. This framework underlies cdid’s treatment of missing outcomes.
Get started · R guide · Stata guide · R on GitHub · Stata on GitHub · CRAN · Research paper
Start with your data
- Prepare a panel and unit table. Supply unit and date identifiers, outcomes and treatment information. Keep missing outcomes as
NA. The guide explains when covariates or information on unobserved units are also required. - Investigate missingness. See which units and pairs are observed and which comparisons have support.
- Estimate and plot treatment effects. Use
att_gt(),aggte()andggdid(), with tables, uncertainty estimates and recorded output.
What chaining and observation models add
An unbalanced panel is a data structure. The assumption that makes its observed outcomes informative is a separate choice. cdid makes that choice explicit and combines the within-unit changes available across dates.
- Representative mean changes. The baseline method needs the observed changes to represent the relevant population’s mean changes. The observed outcome levels need not be representative.
- Conditional representativeness. When observed changes are representative only after conditioning on covariates, choose observation weighting, imputation of actual changes, or an augmented correction combining the two.
- Separate treatment adjustment. IPW, outcome regression and doubly robust treatment adjustment remain separate choices. A treatment propensity is not an observation propensity.
The missingness comparison explains what balancing, repeated-cross-section calculations and fixed-effects regressions already do, and what additional problems cdid addresses. The worked identification example shows a design where within-unit changes identify effects while comparisons of the observed levels do not.
Familiar models in a broader framework
The same package includes ordinary Callaway–Sant’Anna estimation, chained adoption effects, linear cohort-by-date fixed effects, binary static entry and exit, and cross-pair cohort chains. Several familiar specifications can therefore be reproduced within cdid, then extended to incomplete outcomes under the stated assumptions.
The estimator dictionary gives matched commands and results for R and Stata methods. The capability table separates direct delegation, matched specifications and extensions. Equality of a point estimate does not automatically imply equality of finite-sample standard-error conventions or event-study weights.
Install and check your version
install.packages("cdid")
packageVersion("cdid")
vignette("cdid", package = "cdid")
This site documents cdid 1.3.0.0, available on GitHub. Check the CRAN package page for the version currently distributed there. If you need features newer than your CRAN installation, use the GitHub installation instructions.
The native Stata package 1.0.0.0 is also available on GitHub. It requires Stata 19.5 (StataNow) or later.
net install cdid, from("https://raw.githubusercontent.com/dvbn/cdid-stata/main")
mata: mata mlib index
Read the Stata installation guide for ordinary-mode dependencies and the R-to-Stata correspondence for option mappings and inference conventions. The comparison table identifies the implementation behind each match.
Explore and contribute
- Editable practical notebook with synthetic data, fitted equations, coefficient tables and treatment effects.
- Models and assumptions, parallel trends and inference.
- Releases and changes, questions and reproducible bug reports.
To propose another method for inclusion, open an issue on GitHub. Describe the target, reference implementation and the missing-data setting you want to support.
The comparison page also provides JSON and plain Markdown generated from the same maintained descriptions. A documentation index lists the main sources.