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
### Honest DiD Sensitivity Analysis (Rambachan-Roth)
986
+
987
+
Pre-trends tests have low power and can exacerbate bias. **Honest DiD** (Rambachan & Roth 2023) provides sensitivity analysis showing how robust your results are to violations of parallel trends.
988
+
989
+
```python
990
+
from diff_diff import HonestDiD, MultiPeriodDiD
991
+
992
+
# First, fit a standard event study
993
+
did = MultiPeriodDiD()
994
+
event_results = did.fit(
995
+
data,
996
+
outcome='outcome',
997
+
treatment='treated',
998
+
time='period',
999
+
post_periods=[5, 6, 7, 8, 9]
1000
+
)
1001
+
1002
+
# Compute honest bounds with relative magnitudes restriction
1003
+
# M=1 means post-treatment violations can be up to 1x the worst pre-treatment violation
Placebo tests help validate the parallel trends assumption by checking whether effects appear where they shouldn't (before treatment or in untreated groups).
@@ -1278,6 +1355,75 @@ SyntheticDiD(
1278
1355
|`get_unit_weights_df()`| Get unit weights as DataFrame |
1279
1356
|`get_time_weights_df()`| Get time weights as DataFrame |
1280
1357
1358
+
### HonestDiD
1359
+
1360
+
```python
1361
+
HonestDiD(
1362
+
method='relative_magnitude', # 'relative_magnitude' or 'smoothness'
1363
+
M=None, # Restriction parameter (default: 1.0 for RM, 0.0 for SD)
1364
+
alpha=0.05, # Significance level for CIs
1365
+
l_vec=None# Linear combination vector for target parameter
1366
+
)
1367
+
```
1368
+
1369
+
**fit() Parameters:**
1370
+
1371
+
| Parameter | Type | Description |
1372
+
|-----------|------|-------------|
1373
+
|`results`| MultiPeriodDiDResults | Results from MultiPeriodDiD.fit() |
|`fit(results, M)`| Compute bounds for given event study results |
1381
+
|`sensitivity_analysis(results, M_grid)`| Compute bounds over grid of M values |
1382
+
|`breakdown_value(results, tol)`| Find smallest M where CI includes zero |
1383
+
1384
+
### HonestDiDResults
1385
+
1386
+
**Attributes:**
1387
+
1388
+
| Attribute | Description |
1389
+
|-----------|-------------|
1390
+
|`original_estimate`| Point estimate under parallel trends |
1391
+
|`lb`| Lower bound of identified set |
1392
+
|`ub`| Upper bound of identified set |
1393
+
|`ci_lb`| Lower bound of robust confidence interval |
1394
+
|`ci_ub`| Upper bound of robust confidence interval |
1395
+
|`ci_width`| Width of robust CI |
1396
+
|`M`| Restriction parameter used |
1397
+
|`method`| Restriction method ('relative_magnitude' or 'smoothness') |
1398
+
|`alpha`| Significance level |
1399
+
|`is_significant`| True if robust CI excludes zero |
1400
+
1401
+
**Methods:**
1402
+
1403
+
| Method | Description |
1404
+
|--------|-------------|
1405
+
|`summary()`| Get formatted summary string |
1406
+
|`to_dict()`| Convert to dictionary |
1407
+
|`to_dataframe()`| Convert to pandas DataFrame |
1408
+
1409
+
### SensitivityResults
1410
+
1411
+
**Attributes:**
1412
+
1413
+
| Attribute | Description |
1414
+
|-----------|-------------|
1415
+
|`M_grid`| Array of M values analyzed |
1416
+
|`results`| List of HonestDiDResults for each M |
1417
+
|`breakdown_M`| Smallest M where CI includes zero (None if always significant) |
1418
+
1419
+
**Methods:**
1420
+
1421
+
| Method | Description |
1422
+
|--------|-------------|
1423
+
|`summary()`| Get formatted summary string |
1424
+
|`plot(ax)`| Plot sensitivity analysis |
1425
+
|`to_dataframe()`| Convert to pandas DataFrame |
1426
+
1281
1427
### Data Preparation Functions
1282
1428
1283
1429
#### generate_did_data
@@ -1501,9 +1647,23 @@ This library implements methods from the following scholarly works:
1501
1647
1502
1648
-**Roth, J. (2022).** "Pretest with Caution: Event-Study Estimates after Testing for Parallel Trends." *American Economic Review: Insights*, 4(3), 305-322. [https://doi.org/10.1257/aeri.20210236](https://doi.org/10.1257/aeri.20210236)
1503
1649
1650
+
-**Lakens, D. (2017).** "Equivalence Tests: A Practical Primer for t Tests, Correlations, and Meta-Analyses." *Social Psychological and Personality Science*, 8(4), 355-362. [https://doi.org/10.1177/1948550617697177](https://doi.org/10.1177/1948550617697177)
1651
+
1652
+
### Honest DiD / Sensitivity Analysis
1653
+
1654
+
The `HonestDiD` module implements sensitivity analysis methods for relaxing the parallel trends assumption:
1655
+
1504
1656
-**Rambachan, A., & Roth, J. (2023).** "A More Credible Approach to Parallel Trends." *The Review of Economic Studies*, 90(5), 2555-2591. [https://doi.org/10.1093/restud/rdad018](https://doi.org/10.1093/restud/rdad018)
1505
1657
1506
-
-**Lakens, D. (2017).** "Equivalence Tests: A Practical Primer for t Tests, Correlations, and Meta-Analyses." *Social Psychological and Personality Science*, 8(4), 355-362. [https://doi.org/10.1177/1948550617697177](https://doi.org/10.1177/1948550617697177)
1658
+
This paper introduces the "Honest DiD" framework implemented in our `HonestDiD` class:
1659
+
-**Relative Magnitudes (ΔRM)**: Bounds post-treatment violations by a multiple of observed pre-treatment violations
1660
+
-**Smoothness (ΔSD)**: Bounds on second differences of trend violations, allowing for linear extrapolation of pre-trends
1661
+
-**Breakdown Analysis**: Finding the smallest violation magnitude that would overturn conclusions
1662
+
-**Robust Confidence Intervals**: Valid inference under partial identification
1663
+
1664
+
-**Roth, J., & Sant'Anna, P. H. C. (2023).** "When Is Parallel Trends Sensitive to Functional Form?" *Econometrica*, 91(2), 737-747. [https://doi.org/10.3982/ECTA19402](https://doi.org/10.3982/ECTA19402)
1665
+
1666
+
Discusses functional form sensitivity in parallel trends assumptions, relevant to understanding when smoothness restrictions are appropriate.
|**CallawaySantAnna Covariates**| ✅ Implemented | 1.0 Blocker | Conditional PT often required in practice |
23
23
|**API Documentation Site**| Not Started | 1.0 Blocker | Credibility and discoverability |
24
24
| Goodman-Bacon Decomposition | Not Started | 1.0 Target | Explains when TWFE fails |
@@ -35,17 +35,30 @@ A production-ready DiD library needs:
35
35
These features are essential for a credible 1.0 release. Without them, the library has significant gaps compared to R alternatives.
36
36
37
37
### Honest DiD / Sensitivity Analysis (Rambachan-Roth)
38
-
**Status**: Not Started
38
+
**Status**: ✅ Implemented
39
39
**Effort**: High
40
40
**Practitioner Value**: ⭐⭐⭐⭐⭐
41
41
42
42
**Why this matters**: Pre-trends tests have low power and can exacerbate bias. Increasingly, journal reviewers and seminar audiences expect sensitivity analysis showing "how robust are results to violations of parallel trends?" This is becoming as standard as reporting robust SEs.
43
43
44
-
**Features needed**:
45
-
- Compute bounds under restrictions on trend deviations (relative magnitudes)
46
-
- Confidence intervals valid under partial identification
47
-
- Breakdown analysis: "How much violation would nullify the result?"
48
-
- Visualization of sensitivity curves
44
+
**Implemented features**:
45
+
- ✅ Relative magnitudes (ΔRM): Bounds post-treatment violations by M̄ × max pre-period violation
46
+
- ✅ Smoothness (ΔSD): Bounds on second differences of trend violations
47
+
- ✅ Combined restrictions (ΔSDRM): Both smoothness and relative magnitude bounds
48
+
- ✅ FLCI (Fixed Length Confidence Interval) for smoothness restrictions
49
+
- ✅ C-LF (Conditional Least Favorable) for relative magnitudes
50
+
- ✅ Breakdown analysis: Find smallest M where robust CI includes zero
51
+
- ✅ Sensitivity analysis over grid of M values
52
+
- ✅ Visualization: `plot_sensitivity()` and `plot_honest_event_study()`
-[x] Comprehensive test coverage for `utils.py` module (72 tests)
250
276
-[x] Tutorial notebooks in `docs/tutorials/`
@@ -267,10 +293,10 @@ Beyond the API site:
267
293
268
294
## Suggested 1.0 Milestone Plan
269
295
270
-
1.**CallawaySantAnna Covariates** - Makes the staggered estimator production-ready
271
-
2.**Honest DiD (Rambachan-Roth)** - Addresses the key credibility gap
296
+
1.✅ **CallawaySantAnna Covariates** - Makes the staggered estimator production-ready
297
+
2.✅ **Honest DiD (Rambachan-Roth)** - Addresses the key credibility gap
272
298
3.**API Documentation Site** - Professional presentation
273
299
4.**Goodman-Bacon Decomposition** - Key diagnostic for TWFE users
274
300
5.**Power Analysis** - Study design tool practitioners need
275
301
276
-
With these five additions, diff-diff would be competitive with R's `did` + `HonestDiD` ecosystem.
302
+
With items 1-2 complete, diff-diff now has feature parity with R's `did` + `HonestDiD` ecosystem for core sensitivity analysis. The remaining items (3-5) will complete the 1.0 release.
0 commit comments