diddesign
Difference-in-differences (DID) remains the workhorse design for observational causal inference in the social sciences. When multiple pre-treatment periods are available, the standard two-period DID and sequential DID estimators exploit different moment conditions, each valid under its own parallel-trends assumption. diddesign implements the Egami and Yamauchi (2023, Political Analysis) GMM framework that combines these component estimators with efficient weighting, yielding the Double DID estimator.
The package provides a unified Python interface for standard DID, sequential DID, Double DID, K-DID (three or more pre-treatment periods with adaptive J-test moment selection), and staggered-adoption designs with lead-specific estimates. All results are returned as immutable objects with pandas DataFrame accessors for inspection, export, LaTeX table generation, and figure production.
Analysts working with panel data or repeated cross-sections will find a complete workflow: pre-treatment placebo diagnostics via equivalence confidence intervals, treatment effect estimation with bootstrap inference, GMM weight inspection, and publication-ready output in a single package.
Getting started
Install with pip install diddesign, then run the Quick Start example
in User Guide using the built-in Malesky (2014) dataset. Full
workflows are available in Tutorials; concise snippets in
Examples.
Contents:
- User Guide
- Installation
- Quick Start
- Data Requirements
- Designs
- Parameter Selection Guide
- Result Objects
- Reading Returned Rows
- Interpreting Results
- Formula Interface
- Covariates
- Inference
- Visualization
- Built-in Datasets
- Error Handling
- Bootstrap Inference for Staggered Adoption
- Summary Statistic Edge Cases
- Plotting Row Requirements
- Formula Validation
- Time Label Validation
- Boolean Numeric Validation
- Random Seed Validation
- Design Role and Cluster Validation
- Bootstrap and Sequence Validation
- GMM Availability Consistency
- Negative GMM Weights
- Boolean
as_frameValidation - Estimator Filter Validation
- Sequential DID Transformed Outcomes
- SA Component Timing Weights
- SA Placebo Timing Weights
- Dataset Registry
- Tutorials
- Examples
- API Reference