Skip to content

Commit c184e14

Browse files
authored
Merge pull request #263 from igerber/survey-docs-update
Update survey documentation: compatibility matrix, roadmap, deferred work
2 parents ff63fd5 + 2fee9b4 commit c184e14

7 files changed

Lines changed: 323 additions & 105 deletions

File tree

ROADMAP.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ For past changes and release history, see [CHANGELOG.md](CHANGELOG.md).
88

99
## Current Status
1010

11-
diff-diff v2.7.5 is a **production-ready** DiD library with feature parity with R's `did` + `HonestDiD` + `synthdid` ecosystem for core DiD analysis, plus **unique survey support**design-based variance estimation (Taylor linearization, replicate weights) integrated across all estimators. No R or Python package offers this combination:
11+
diff-diff v2.8.4 is a **production-ready** DiD library with feature parity with R's `did` + `HonestDiD` + `synthdid` ecosystem for core DiD analysis, plus **unique survey support**all estimators accept survey weights, with design-based variance estimation varying by estimator. No R or Python package offers this combination:
1212

13-
- **Core estimators**: Basic DiD, TWFE, MultiPeriod, Callaway-Sant'Anna, Sun-Abraham, Borusyak-Jaravel-Spiess Imputation, Synthetic DiD, Triple Difference (DDD), TROP, Two-Stage DiD (Gardner 2022), Stacked DiD (Wing et al. 2024), Continuous DiD (Callaway, Goodman-Bacon & Sant'Anna 2024)
13+
- **Core estimators**: Basic DiD, TWFE, MultiPeriod, Callaway-Sant'Anna, Sun-Abraham, Borusyak-Jaravel-Spiess Imputation, Synthetic DiD, Triple Difference (DDD), Staggered Triple Difference (Ortiz-Villavicencio & Sant'Anna 2025), TROP, Two-Stage DiD (Gardner 2022), Stacked DiD (Wing et al. 2024), Continuous DiD (Callaway, Goodman-Bacon & Sant'Anna 2024)
1414
- **Valid inference**: Robust SEs, cluster SEs, wild bootstrap, multiplier bootstrap, placebo-based variance
1515
- **Assumption diagnostics**: Parallel trends tests, placebo tests, Goodman-Bacon decomposition
1616
- **Sensitivity analysis**: Honest DiD (Rambachan-Roth), Pre-trends power analysis (Roth 2022)
1717
- **Study design**: Power analysis tools
1818
- **Data utilities**: Real-world datasets (Card-Krueger, Castle Doctrine, Divorce Laws, MPDTA), DGP functions for all supported designs
19-
- **Survey support**: Full `SurveyDesign` with strata, PSU, FPC, weight types, replicate weights (BRR/Fay/JK1/JKn), Taylor linearization, DEFF diagnostics, subpopulation analysis — integrated across all estimators (see [survey-roadmap.md](docs/survey-roadmap.md))
19+
- **Survey support**: `SurveyDesign` with strata, PSU, FPC, weight types, DEFF diagnostics, subpopulation analysis. All 15 estimators accept survey weights; design-based variance estimation (TSL, replicate weights, survey-aware bootstrap) varies by estimator. Replicate weights (BRR/Fay/JK1/JKn/SDR) supported for 12 of 15; `BaconDecomposition` is diagnostic-only. See [choosing_estimator.rst](docs/choosing_estimator.rst#survey-design-support) for the full compatibility matrix.
2020
- **Performance**: Optional Rust backend for accelerated computation; faster than R at scale (see [CHANGELOG.md](CHANGELOG.md) for benchmarks)
2121

2222
---
@@ -34,19 +34,20 @@ full details.
3434
- **Repeated Cross-Sections** *(Implemented)*: `panel=False` support for
3535
CallawaySantAnna using cross-sectional DRDID (Sant'Anna & Zhao 2020,
3636
Section 4). Supports BRFSS, ACS annual, CPS monthly.
37-
- **Survey-Aware DiD Tutorial** *(Open)*: Jupyter notebook demonstrating
37+
- **Survey-Aware DiD Tutorial** *(Implemented)*: Jupyter notebook demonstrating
3838
the full workflow with realistic survey data.
3939
- **HonestDiD + Survey Variance** *(Implemented)*: Survey df and full
4040
event-study VCV propagated to sensitivity analysis, with bootstrap/replicate
4141
diagonal fallback.
4242

43-
### Staggered Triple Difference (DDD)
43+
### Staggered Triple Difference (DDD) *(Implemented)*
4444

45-
Extend the existing `TripleDifference` estimator to handle staggered adoption settings.
45+
`StaggeredTripleDifference` estimator for staggered adoption DDD settings.
4646

4747
- Group-time ATT(g,t) for DDD designs with variation in treatment timing
4848
- Event study aggregation and pre-treatment placebo effects
4949
- Multiplier bootstrap for valid inference in staggered settings
50+
- Full survey support (pweight, strata/PSU/FPC, replicate weights)
5051

5152
**Reference**: [Ortiz-Villavicencio & Sant'Anna (2025)](https://arxiv.org/abs/2505.09942). "Better Understanding Triple Differences Estimators." *Working Paper*. R package: `triplediff`.
5253

TODO.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ Current limitations that may affect users:
1515
| MultiPeriodDiD wild bootstrap not supported | `estimators.py:778-784` | Low | Edge case |
1616
| `predict()` raises NotImplementedError | `estimators.py:567-588` | Low | Rarely needed |
1717

18+
For survey-specific limitations (NotImplementedError paths), see the
19+
[consolidated deferred list](docs/survey-roadmap.md#deferred-work-consolidated)
20+
in survey-roadmap.md.
21+
1822
## Code Quality
1923

2024
### Large Module Files

diff_diff/survey.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,8 +1087,7 @@ def _resolve_survey_for_fit(survey_design, data, inference_mode="analytical"):
10871087
if inference_mode == "wild_bootstrap":
10881088
raise NotImplementedError(
10891089
"Wild bootstrap with survey weights is not yet supported. "
1090-
"Use inference='analytical' with survey_design, or see "
1091-
"docs/survey-roadmap.md for planned Phase 5 support."
1090+
"Use analytical survey inference (the default) instead."
10921091
)
10931092

10941093
resolved = survey_design.resolve(data)

docs/choosing_estimator.rst

Lines changed: 121 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,5 +571,124 @@ If you're unsure which estimator to use:
571571
investigate why (often reveals violations of assumptions)
572572

573573
5. **Using survey data?** - Pass a ``SurveyDesign`` to ``fit()`` for design-based
574-
variance estimation. See the `survey tutorial <https://github.com/igerber/diff-diff/blob/main/docs/tutorials/16_survey_did.ipynb>`_
575-
for a full walkthrough with strata, PSU, FPC, replicate weights, and subpopulation analysis.
574+
variance estimation. See the :ref:`survey-design-support` section below for
575+
the compatibility matrix, and the `survey tutorial <https://github.com/igerber/diff-diff/blob/main/docs/tutorials/16_survey_did.ipynb>`_
576+
for a full walkthrough.
577+
578+
.. _survey-design-support:
579+
580+
Survey Design Support
581+
---------------------
582+
583+
All estimators accept an optional ``survey_design`` parameter in ``fit()``.
584+
Pass a :class:`~diff_diff.SurveyDesign` object to get design-based variance
585+
estimation. The depth of support varies by estimator:
586+
587+
.. list-table::
588+
:header-rows: 1
589+
:widths: 25 12 18 18 18
590+
591+
* - Estimator
592+
- Weights
593+
- Strata/PSU/FPC
594+
- Replicate Weights
595+
- Survey Bootstrap
596+
* - ``DifferenceInDifferences``
597+
- Full
598+
- Full
599+
- Full
600+
- --
601+
* - ``TwoWayFixedEffects``
602+
- Full
603+
- Full
604+
- Full
605+
- --
606+
* - ``MultiPeriodDiD``
607+
- Full
608+
- Full
609+
- Full
610+
- --
611+
* - ``CallawaySantAnna``
612+
- pweight only
613+
- Full
614+
- Full
615+
- Multiplier at PSU
616+
* - ``TripleDifference``
617+
- pweight only
618+
- Full
619+
- Full (analytical)
620+
- --
621+
* - ``StaggeredTripleDifference``
622+
- pweight only
623+
- Full
624+
- Full
625+
- Multiplier at PSU
626+
* - ``SunAbraham``
627+
- Full
628+
- Full
629+
- Full
630+
- Rao-Wu rescaled
631+
* - ``StackedDiD``
632+
- pweight only
633+
- Full (pweight only)
634+
- Full
635+
- --
636+
* - ``ImputationDiD``
637+
- pweight only
638+
- Full
639+
- Full (analytical)
640+
- Multiplier at PSU
641+
* - ``TwoStageDiD``
642+
- pweight only
643+
- Full
644+
- Full (analytical)
645+
- Multiplier at PSU
646+
* - ``ContinuousDiD``
647+
- Full
648+
- Full
649+
- Full (analytical)
650+
- Multiplier at PSU
651+
* - ``EfficientDiD``
652+
- Full
653+
- Full
654+
- Full (analytical)
655+
- Multiplier at PSU
656+
* - ``SyntheticDiD``
657+
- pweight only
658+
- Via bootstrap
659+
- --
660+
- Rao-Wu rescaled
661+
* - ``TROP``
662+
- pweight only
663+
- Via bootstrap
664+
- --
665+
- Rao-Wu rescaled
666+
* - ``BaconDecomposition``
667+
- Diagnostic
668+
- Diagnostic
669+
- --
670+
- --
671+
672+
**Legend:**
673+
674+
- **Full**: All weight types (pweight/fweight/aweight) + strata/PSU/FPC + Taylor Series Linearization variance
675+
- **Full (pweight only)**: Full TSL with strata/PSU/FPC, but only ``pweight`` accepted (``fweight``/``aweight`` rejected because composition changes weight semantics)
676+
- **Via bootstrap**: Strata/PSU/FPC supported only with bootstrap variance. ``SyntheticDiD`` requires ``variance_method='bootstrap'``; ``TROP`` uses bootstrap by default. ``SyntheticDiD`` placebo does not support strata/PSU/FPC.
677+
- **pweight only** (Weights column): Only ``pweight`` accepted; ``fweight``/``aweight`` raise an error
678+
- **Diagnostic**: Weighted descriptive statistics only (no inference)
679+
- **--**: Not supported
680+
681+
.. note::
682+
683+
``EfficientDiD`` does not support ``covariates`` and ``survey_design``
684+
simultaneously (the DR nuisance path does not yet thread survey weights).
685+
686+
.. note::
687+
688+
``SyntheticDiD`` with ``variance_method='placebo'`` does not support
689+
strata/PSU/FPC. Use ``variance_method='bootstrap'`` for full survey
690+
design support.
691+
692+
For the full walkthrough with code examples, see the
693+
`survey tutorial <https://github.com/igerber/diff-diff/blob/main/docs/tutorials/16_survey_did.ipynb>`_.
694+
For deferred work and remaining limitations, see ``docs/survey-roadmap.md``.

docs/methodology/REGISTRY.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2307,10 +2307,11 @@ variance from the distribution of replicate estimates.
23072307
design structure is fixed and dropped replicates contribute zero to the
23082308
sum without changing the scale. Survey df uses `n_valid - 1` for
23092309
t-based inference.
2310-
- **Note:** Replicate-weight support matrix:
2311-
- **Supported**: CallawaySantAnna (reg/ipw/dr without covariates, no
2312-
bootstrap), ContinuousDiD (no bootstrap), EfficientDiD (no bootstrap),
2313-
TripleDifference (all methods), LinearRegression (OLS path),
2310+
- **Note:** Replicate-weight support matrix (12 of 15 public estimators):
2311+
- **Supported**: CallawaySantAnna (reg/ipw/dr with or without covariates,
2312+
no bootstrap; IF-based replicate variance is covariate-agnostic),
2313+
ContinuousDiD (no bootstrap), EfficientDiD (no bootstrap),
2314+
TripleDifference (all methods), StaggeredTripleDifference (IF-based),
23142315
DifferenceInDifferences (no-absorb via LinearRegression dispatch,
23152316
absorb via estimator-level refit), MultiPeriodDiD (no-absorb via
23162317
`compute_replicate_vcov`, absorb via estimator-level refit),

0 commit comments

Comments
 (0)