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
Address PR #113 Round 2 feedback: true NaN exclusion and jackknife fixes
- Fix _solve_joint_with_lowrank to mask delta for NaN observations
(ensures NaN Y values don't contribute to gradient step)
- Fix jackknife to use true leave-one-out via weight zeroing
(removes incorrect imputation with column means)
- Handle units with no valid pre-period data by setting delta_unit=0
(previously got max weight due to dist=0)
- Document simultaneous adoption assumption for joint method variance
- Correct notebook weight normalization statement (not "sum to one")
- Add tests for true NaN exclusion and jackknife variation behavior
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/tutorials/10_trop.ipynb
+3-44Lines changed: 3 additions & 44 deletions
Original file line number
Diff line number
Diff line change
@@ -3,29 +3,7 @@
3
3
{
4
4
"cell_type": "markdown",
5
5
"metadata": {},
6
-
"source": [
7
-
"# Triply Robust Panel (TROP) Estimator\n",
8
-
"\n",
9
-
"This notebook demonstrates the **Triply Robust Panel (TROP)** estimator (Athey, Imbens, Qu & Viviano, 2025), which combines three robustness components:\n",
10
-
"\n",
11
-
"1. **Nuclear Norm Regularized Factor Model**: Estimates interactive fixed effects via matrix completion with nuclear norm penalty\n",
12
-
"2. **Exponential Distance-Based Unit Weights**: ω_j = exp(-λ_unit × dist(j,i)) where dist(j,i) is the root mean squared difference in outcomes between units j and i, computed only on periods where both units are untreated and excluding the target period t (Equation 3 in the paper)\n",
13
-
"3. **Exponential Time Decay Weights**: θ_s = exp(-λ_time × |s-t|) weighting by proximity to treatment\n",
14
-
"\n",
15
-
"**Weight Normalization**: Following the paper, the observation-specific weights ω and θ are treated as probability weights that effectively sum to one within each treated observation's counterfactual estimation.\n",
16
-
"\n",
17
-
"TROP is particularly useful when:\n",
18
-
"- There may be unobserved time-varying confounders with factor structure\n",
19
-
"- Standard DiD or SDID may be biased due to latent factors\n",
20
-
"- You want robust inference under factor confounding\n",
21
-
"\n",
22
-
"We'll cover:\n",
23
-
"1. When to use TROP\n",
24
-
"2. Basic estimation with LOOCV tuning\n",
25
-
"3. Understanding tuning parameters\n",
26
-
"4. Examining factor structure\n",
27
-
"5. Comparing TROP vs SDID"
28
-
]
6
+
"source": "# Triply Robust Panel (TROP) Estimator\n\nThis notebook demonstrates the **Triply Robust Panel (TROP)** estimator (Athey, Imbens, Qu & Viviano, 2025), which combines three robustness components:\n\n1. **Nuclear Norm Regularized Factor Model**: Estimates interactive fixed effects via matrix completion with nuclear norm penalty\n2. **Exponential Distance-Based Unit Weights**: ω_j = exp(-λ_unit × dist(j,i)) where dist(j,i) is the root mean squared difference in outcomes between units j and i, computed only on periods where both units are untreated and excluding the target period t (Equation 3 in the paper)\n3. **Exponential Time Decay Weights**: θ_s = exp(-λ_time × |s-t|) weighting by proximity to treatment\n\n**Weights**: The observation-specific weights ω and θ are importance weights that control the relative contribution of each observation to counterfactual estimation. Higher weights indicate more relevant observations for the target counterfactual.\n\nTROP is particularly useful when:\n- There may be unobserved time-varying confounders with factor structure\n- Standard DiD or SDID may be biased due to latent factors\n- You want robust inference under factor confounding\n\nWe'll cover:\n1. When to use TROP\n2. Basic estimation with LOOCV tuning\n3. Understanding tuning parameters\n4. Examining factor structure\n5. Comparing TROP vs SDID"
29
7
},
30
8
{
31
9
"cell_type": "code",
@@ -693,7 +671,7 @@
693
671
"execution_count": null,
694
672
"metadata": {},
695
673
"outputs": [],
696
-
"source": "## Summary\n\nKey takeaways for TROP:\n\n1. **Best use cases**: Factor confounding, unobserved time-varying confounders with interactive effects\n2. **Factor estimation**: Nuclear norm regularization with LOOCV for tuning\n3. **Three tuning parameters**: λ_time, λ_unit, λ_nn selected automatically via LOOCV\n4. **Unit weights**: Exponential distance-based weighting of control units, where distance is computed as RMS outcome difference on control periods excluding the target period\n5. **Time weights**: Exponential decay weighting of pre-treatment periods\n6. **Weight normalization**: Weights are treated as probability weights that sum to one\n7. **Estimation methods**:\n - `method='twostep'` (default): Per-observation estimation, allows heterogeneous effects\n - `method='joint'`: Single scalar treatment effect, faster but assumes homogeneity\n\n**When to use TROP vs SDID**:\n- Use **SDID** when parallel trends is plausible and factors are not a concern\n- Use **TROP** when you suspect factor confounding (regional shocks, economic cycles, latent factors)\n- Running both provides a useful robustness check\n\n**When to use twostep vs joint method**:\n- Use **twostep** (default) for maximum flexibility and heterogeneous treatment effects\n- Use **joint** for faster estimation when effects are expected to be homogeneous\n\n**Reference**:\n- Athey, S., Imbens, G. W., Qu, Z., & Viviano, D. (2025). Triply Robust Panel Estimators. *Working Paper*. https://arxiv.org/abs/2508.21536"
674
+
"source": "## Summary\n\nKey takeaways for TROP:\n\n1. **Best use cases**: Factor confounding, unobserved time-varying confounders with interactive effects\n2. **Factor estimation**: Nuclear norm regularization with LOOCV for tuning\n3. **Three tuning parameters**: λ_time, λ_unit, λ_nn selected automatically via LOOCV\n4. **Unit weights**: Exponential distance-based weighting of control units, where distance is computed as RMS outcome difference on control periods excluding the target period\n5. **Time weights**: Exponential decay weighting of pre-treatment periods\n6. **Weights**: Importance weights controlling relative contribution of observations (higher = more relevant)\n7. **Estimation methods**:\n - `method='twostep'` (default): Per-observation estimation, allows heterogeneous effects\n - `method='joint'`: Single scalar treatment effect, faster but assumes homogeneity\n\n**When to use TROP vs SDID**:\n- Use **SDID** when parallel trends is plausible and factors are not a concern\n- Use **TROP** when you suspect factor confounding (regional shocks, economic cycles, latent factors)\n- Running both provides a useful robustness check\n\n**When to use twostep vs joint method**:\n- Use **twostep** (default) for maximum flexibility and heterogeneous treatment effects\n- Use **joint** for faster estimation when effects are expected to be homogeneous\n\n**Reference**:\n- Athey, S., Imbens, G. W., Qu, Z., & Viviano, D. (2025). Triply Robust Panel Estimators. *Working Paper*. https://arxiv.org/abs/2508.21536"
697
675
},
698
676
{
699
677
"cell_type": "code",
@@ -710,26 +688,7 @@
710
688
{
711
689
"cell_type": "markdown",
712
690
"metadata": {},
713
-
"source": [
714
-
"## Summary\n",
715
-
"\n",
716
-
"Key takeaways for TROP:\n",
717
-
"\n",
718
-
"1. **Best use cases**: Factor confounding, unobserved time-varying confounders with interactive effects\n",
719
-
"2. **Factor estimation**: Nuclear norm regularization with LOOCV for tuning\n",
"4. **Unit weights**: Exponential distance-based weighting of control units, where distance is computed as RMS outcome difference on control periods excluding the target period\n",
722
-
"5. **Time weights**: Exponential decay weighting of pre-treatment periods\n",
723
-
"6. **Weight normalization**: Weights are treated as probability weights that sum to one\n",
724
-
"\n",
725
-
"**When to use TROP vs SDID**:\n",
726
-
"- Use **SDID** when parallel trends is plausible and factors are not a concern\n",
727
-
"- Use **TROP** when you suspect factor confounding (regional shocks, economic cycles, latent factors)\n",
728
-
"- Running both provides a useful robustness check\n",
729
-
"\n",
730
-
"**Reference**:\n",
731
-
"- Athey, S., Imbens, G. W., Qu, Z., & Viviano, D. (2025). Triply Robust Panel Estimators. *Working Paper*. https://arxiv.org/abs/2508.21536"
732
-
]
691
+
"source": "## Summary\n\nKey takeaways for TROP:\n\n1. **Best use cases**: Factor confounding, unobserved time-varying confounders with interactive effects\n2. **Factor estimation**: Nuclear norm regularization with LOOCV for tuning\n3. **Three tuning parameters**: λ_time, λ_unit, λ_nn selected automatically via LOOCV\n4. **Unit weights**: Exponential distance-based weighting of control units, where distance is computed as RMS outcome difference on control periods excluding the target period\n5. **Time weights**: Exponential decay weighting of pre-treatment periods\n6. **Weights**: Importance weights controlling relative contribution of observations (higher = more relevant)\n\n**When to use TROP vs SDID**:\n- Use **SDID** when parallel trends is plausible and factors are not a concern\n- Use **TROP** when you suspect factor confounding (regional shocks, economic cycles, latent factors)\n- Running both provides a useful robustness check\n\n**Reference**:\n- Athey, S., Imbens, G. W., Qu, Z., & Viviano, D. (2025). Triply Robust Panel Estimators. *Working Paper*. https://arxiv.org/abs/2508.21536"
0 commit comments