Discover and explore top open-source AI tools and projects—updated daily.
igerberPython library for advanced Difference-in-Differences causal inference
Top 92.7% on SourcePulse
Summary
igerber/diff-diff is a Python library designed for advanced Difference-in-Differences (DiD) causal inference. It provides a comprehensive suite of estimators, including cutting-edge methods for staggered adoption, event studies, and synthetic DiD, packaged with an sklearn-like API and statsmodels-style outputs. The library targets econometricians, marketing analysts, and data scientists, enabling rigorous causal inference for campaign-lift, policy evaluation, and staggered-rollout analyses through integrated diagnostics and sensitivity analysis tools.
How It Works
The library implements a wide array of DiD estimators, such as Callaway-Sant'Anna (CS), Sun-Abraham (SA), de Chaisemartin & D'Haultfœuille (DCDH) for reversible treatments, and SpilloverDiD. It promotes a rigorous 8-step practitioner workflow (Baker et al. 2025) that guides users through assumption testing, sensitivity analysis, and robustness checks, aiming for more reliable causal estimates than basic model fitting. The API is designed to be familiar to users of scikit-learn, while outputs resemble those from statsmodels for enhanced interpretability.
Quick Start & Requirements
Installation is performed using pip: pip install diff-diff. For development, clone the repository and install with pip install -e ".[dev]". The library requires Python 3.9-3.14 and standard numerical libraries including numpy (>=1.20), pandas (>=1.3), and scipy (>=1.7). Comprehensive documentation, tutorials, quick-start guides, and API references are available.
Highlighted Details
get_llm_guide) for AI agents, offering concise API references and structured practitioner workflows.Maintenance & Community
The project is primarily authored by Isaac Gerber, with contributions acknowledged collectively. Specific community channels (e.g., Discord, Slack) or sponsorship details are not prominently featured in the README.
Licensing & Compatibility
The library is released under the permissive MIT License, which allows for broad compatibility with commercial and closed-source applications.
Limitations & Caveats
Some reporting classes (BusinessReport, DiagnosticReport) are marked as experimental preview features. The HeterogeneousAdoptionDiD estimator is currently panel-only in this release. Specific estimators may have limitations regarding the types of survey weights they accept.
21 hours ago
Inactive
socialfoundations