You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Two-Stage DiD addresses TWFE bias in staggered adoption designs by estimating unit and time fixed effects on untreated observations only, then regressing the residualized outcomes on treatment indicators. Point estimates match the Imputation DiD estimator (Borusyak et al. 2024); the key difference is that Two-Stage DiD uses a GMM sandwich variance estimator that accounts for first-stage estimation error, while Imputation DiD uses a conservative variance (Theorem 3).
rank_deficient_action='warn', # 'warn', 'error', or 'silent'
962
+
horizon_max=None, # Max event-study horizon
963
+
)
964
+
```
965
+
966
+
**When to use Two-Stage DiD vs Imputation DiD:**
967
+
968
+
| Aspect | Two-Stage DiD | Imputation DiD |
969
+
|--------|--------------|---------------|
970
+
| Point estimates | Identical | Identical |
971
+
| Variance | GMM sandwich (accounts for first-stage error) | Conservative (Theorem 3, may overcover) |
972
+
| Intuition | Residualize then regress | Impute counterfactuals then aggregate |
973
+
| Reference impl. | R `did2s` package | R `didimputation` package |
974
+
975
+
Both estimators are the efficient estimator under homogeneous treatment effects, producing shorter confidence intervals than Callaway-Sant'Anna or Sun-Abraham.
976
+
930
977
### Triple Difference (DDD)
931
978
932
979
Triple Difference (DDD) is used when treatment requires satisfying two criteria: belonging to a treated **group** AND being in an eligible **partition**. The `TripleDifference` class implements the methodology from Ortiz-Villavicencio & Sant'Anna (2025), which correctly handles covariate adjustment (unlike naive implementations).
@@ -2104,6 +2151,58 @@ ImputationDiD(
2104
2151
|`to_dataframe(level)`| Convert to DataFrame ('observation', 'event_study', 'group') |
2105
2152
|`pretrend_test(n_leads)`| Run pre-trend F-test (Equation 9) |
2106
2153
2154
+
### TwoStageDiD
2155
+
2156
+
```python
2157
+
TwoStageDiD(
2158
+
anticipation=0, # Periods of anticipation effects
2159
+
alpha=0.05, # Significance level for CIs
2160
+
cluster=None, # Column for cluster-robust SEs (defaults to unit)
|`balance_e`| int | Balance event study to this many pre-treatment periods |
2180
+
2181
+
### TwoStageDiDResults
2182
+
2183
+
**Attributes:**
2184
+
2185
+
| Attribute | Description |
2186
+
|-----------|-------------|
2187
+
|`overall_att`| Overall average treatment effect on the treated |
2188
+
|`overall_se`| Standard error (GMM sandwich variance) |
2189
+
|`overall_t_stat`| T-statistic |
2190
+
|`overall_p_value`| P-value for H0: ATT = 0 |
2191
+
|`overall_conf_int`| Confidence interval |
2192
+
|`event_study_effects`| Dict of relative time -> effect dict (if `aggregate='event_study'` or `'all'`) |
2193
+
|`group_effects`| Dict of cohort -> effect dict (if `aggregate='group'` or `'all'`) |
2194
+
|`treatment_effects`| DataFrame of unit-level treatment effects |
2195
+
|`n_treated_obs`| Number of treated observations |
2196
+
|`n_untreated_obs`| Number of untreated observations |
2197
+
2198
+
**Methods:**
2199
+
2200
+
| Method | Description |
2201
+
|--------|-------------|
2202
+
|`summary(alpha)`| Get formatted summary string |
2203
+
|`print_summary(alpha)`| Print summary to stdout |
2204
+
|`to_dataframe(level)`| Convert to DataFrame ('observation', 'event_study', 'group') |
2205
+
2107
2206
### TripleDifference
2108
2207
2109
2208
```python
@@ -2582,6 +2681,10 @@ The `HonestDiD` module implements sensitivity analysis methods for relaxing the
2582
2681
2583
2682
-**Sun, L., & Abraham, S. (2021).** "Estimating Dynamic Treatment Effects in Event Studies with Heterogeneous Treatment Effects." *Journal of Econometrics*, 225(2), 175-199. [https://doi.org/10.1016/j.jeconom.2020.09.006](https://doi.org/10.1016/j.jeconom.2020.09.006)
2584
2683
2684
+
-**Gardner, J. (2022).** "Two-stage differences in differences." *arXiv preprint arXiv:2207.05943*. [https://arxiv.org/abs/2207.05943](https://arxiv.org/abs/2207.05943)
2685
+
2686
+
-**Butts, K., & Gardner, J. (2022).** "did2s: Two-Stage Difference-in-Differences." *The R Journal*, 14(1), 162-173. [https://doi.org/10.32614/RJ-2022-048](https://doi.org/10.32614/RJ-2022-048)
-**Goodman-Bacon, A. (2021).** "Difference-in-Differences with Variation in Treatment Timing." *Journal of Econometrics*, 225(2), 254-277. [https://doi.org/10.1016/j.jeconom.2021.03.014](https://doi.org/10.1016/j.jeconom.2021.03.014)
0 commit comments