Skip to content

Commit 525ac13

Browse files
authored
Merge pull request #110 from igerber/fix/trop-methodology-alignment
Align TROP with paper methodology (Equation 5, D matrix semantics)
2 parents da2d648 + 3a708fc commit 525ac13

9 files changed

Lines changed: 1936 additions & 416 deletions

File tree

README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,13 +1138,15 @@ trop_est = TROP(
11381138
lambda_nn_grid=[0.0, 0.1, 1.0], # Nuclear norm grid
11391139
n_bootstrap=200
11401140
)
1141+
# Note: TROP infers treatment periods from the treatment indicator column.
1142+
# The 'treated' column must be an absorbing state (D=1 for all periods
1143+
# during and after treatment starts for each unit).
11411144
results = trop_est.fit(
11421145
panel_data,
11431146
outcome='gdp_growth',
11441147
treatment='treated',
11451148
unit='state',
1146-
time='year',
1147-
post_periods=[2015, 2016, 2017, 2018]
1149+
time='year'
11481150
)
11491151

11501152
# View results
@@ -1232,9 +1234,11 @@ sdid_results = sdid.fit(data, outcome='y', treatment='treated',
12321234
unit='unit', time='time', post_periods=[5,6,7])
12331235

12341236
# TROP (accounts for factors)
1237+
# Note: TROP infers treatment periods from the treatment indicator column
1238+
# (D=1 for treated observations, D=0 for control)
12351239
trop_est = TROP() # Uses default grids with LOOCV selection
12361240
trop_results = trop_est.fit(data, outcome='y', treatment='treated',
1237-
unit='unit', time='time', post_periods=[5,6,7])
1241+
unit='unit', time='time')
12381242

12391243
print(f"SDID estimate: {sdid_results.att:.3f}")
12401244
print(f"TROP estimate: {trop_results.att:.3f}")
@@ -1279,13 +1283,13 @@ TROP(
12791283

12801284
```python
12811285
# One-liner estimation with default tuning grids
1286+
# Note: TROP infers treatment periods from the treatment indicator
12821287
results = trop(
12831288
data,
12841289
outcome='y',
12851290
treatment='treated',
12861291
unit='unit',
12871292
time='time',
1288-
post_periods=[5, 6, 7],
12891293
n_bootstrap=200
12901294
)
12911295
```
@@ -1877,10 +1881,11 @@ TROP(
18771881
|-----------|------|-------------|
18781882
| `data` | DataFrame | Panel data |
18791883
| `outcome` | str | Outcome variable column name |
1880-
| `treatment` | str | Treatment indicator column (0/1) |
1884+
| `treatment` | str | Treatment indicator column (0/1 absorbing state) |
18811885
| `unit` | str | Unit identifier column |
18821886
| `time` | str | Time period column |
1883-
| `post_periods` | list | List of post-treatment period values |
1887+
1888+
Note: TROP infers treatment periods from the treatment indicator column. The treatment column should be an absorbing state indicator where D=1 for all periods during and after treatment starts.
18841889

18851890
### TROPResults
18861891

@@ -1906,8 +1911,8 @@ TROP(
19061911
| `factor_matrix` | Low-rank factor matrix L (n_periods x n_units) |
19071912
| `effective_rank` | Effective rank of factor matrix |
19081913
| `loocv_score` | LOOCV score for selected parameters |
1909-
| `pre_periods` | List of pre-treatment periods |
1910-
| `post_periods` | List of post-treatment periods |
1914+
| `n_pre_periods` | Number of pre-treatment periods |
1915+
| `n_post_periods` | Number of post-treatment periods |
19111916
| `variance_method` | Variance estimation method |
19121917
| `bootstrap_distribution` | Bootstrap distribution (if bootstrap) |
19131918

ROADMAP.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ Two-stage approach gaining traction in applied work. First residualizes outcomes
4444

4545
**Reference**: Gardner (2022). *Working Paper*.
4646

47+
### Stacked Difference-in-Differences
48+
49+
An intuitive approach that explicitly constructs sub-experiments for each treatment cohort, avoiding forbidden comparisons.
50+
51+
- Creates separate datasets per cohort with valid controls only
52+
- Stacks sub-experiments and applies corrective sample weights
53+
- Returns variance-weighted ATT with proper compositional balance
54+
- Conceptually simpler alternative to aggregation-based methods
55+
56+
**Reference**: [Wing, Freedman & Hollingsworth (2024)](https://www.nber.org/papers/w32054). *NBER Working Paper 32054*. Stata: `STACKDID`.
57+
4758
### Staggered Triple Difference (DDD)
4859

4960
Extend the existing `TripleDifference` estimator to handle staggered adoption settings. The current implementation handles 2-period DDD; this extends to multi-period designs.

0 commit comments

Comments
 (0)