9.5. Modern Heterogeneity-Robust Staggered Difference-in-Differences
Methodological Part 9.5. Modern Heterogeneity-Robust Staggered Difference-in-Differences in 9. Causal Inference and Modern Policy Evaluation provides step-by-step How-To implementation guides for 15 econometric model lessons spanning from Section 9.5.1 to 9.5.15. Full theoretical derivations are available at VietLOD Part 9.5 alongside cloud execution on EcoLab.
Video Tutorial: How-To Guide for Part 9.5: Modern Heterogeneity-Robust Staggered Difference-in-Differences in Stata 18, R 4.x, and Python 3.11+
9.5.1. Methodological Overview and Structural Equations
- Methodological Focus: Provides consistent estimation and robust inference for Modern Heterogeneity-Robust Staggered Difference-in-Differences specifications within Causal Inference and Modern Policy Evaluation.
- Mandatory Post-Estimation Diagnostics: Tổng tỷ trọng và ước lượng DID trung bình theo 3 nhóm, tỷ phần trọng số bị ô nhiễm động học..
Core structural specification for Part 9.5:
Estimator objective and moment conditions:
9.5.2. Econometric Model Lessons in Part 9.5
Decomposes the canonical staggered TWFE coefficient into exact 2x2 DID comparisons across Treated vs Untreated, Early vs Late, and forbidden...
Estimates saturated cohort-specific dynamic treatment effects relative to never-treated or last-treated controls and aggregates them by empi...
Fits unit, time, and covariate effects exclusively on untreated observations Omega_0 to impute counterfactual Y — 0 — and aggregate unbiased...
Compares units switching treatment status against clean control units holding the same baseline treatment status unchanged, allowing policie...
Restores full heterogeneity robustness to two-way fixed effects by saturating cohort-by-post-time cells alongside cohort-demeaned covariate ...
Combines horizon-by-horizon local projections with clean-control sample pruning so already-treated units never contaminate dynamic treatment...
Constructs robust partial-identification confidence intervals when post-treatment trend violations are bounded by M_bar times the worst pre-...
Combines ridge-regularized simplex donor unit weights and pre-treatment time weights inside a two-way fixed-effects regression for doubly ro...
9.5.3. Comparative Execution Syntax Across Stata 18, R 4.x, and Python 3.11+
| Section & Model Title | Estimator Key | Stata 18 MP Syntax | R 4.x Syntax | Python 3.11+ Syntax | Support |
|---|---|---|---|---|---|
| 9.5.1 · Goodman-Bacon Staggered TWFE Weight Decomposition | bacon_decomposition | bacondecomp y treat, ddetail | bacondecomp::bacon(y ~ treat, data = df, id_var = 'id', time_var = 'year') | PanelOLS.from_formula('y ~ 1 + treat + EntityEffects + TimeEffects', data=pdata).fit() | Available |
| 9.5.2 · Sun-Abraham Interaction-Weighted Event-Study DID | sun_abraham_did | eventstudyinteract y lead* lag*, cohort(first_treat) control_cohort(never) absorb(id year) vce(cluster id) | fixest::feols(y ~ x1 + sunab(first_treat, year) | id + year, cluster = ~id, data = df) | pyfixest.event_study(df, yname='y', idname='id', tname='year', gname='first_treat', estimator='saturated') | Available |
| 9.5.3 · Borusyak-Jaravel-Spiess Counterfactual Imputation DID | borusyak_imputation_did | did_imputation y id year first_treat, horizons(0/5) pretrends(4) | did2s::did2s(df, yname = 'y', first_stage = ~ 0 | id + year, second_stage = ~ i(rel_time), treatment = 'treat', cluster_var = 'id') | pyfixest.did2s(df, yname='y', first_stage='~ 0 | id + year', second_stage='~ treat', treatment='treat', cluster='id') | Available |
| 9.5.4 · De Chaisemartin Dynamic Switching Treatment DID | dechaisemartin_did | did_multiplegt_dyn y id year treat, effects(5) placebo(3) cluster(id) | DIDmultiplegtDYN::did_multiplegt_dyn(df, 'y', 'id', 'year', 'treat', effects = 5, placebo = 3) | PanelOLS.from_formula('dy ~ 1 + d_treat + x1 + TimeEffects', data=pdata).fit(cov_type='clustered', cluster_entity=True) | Available |
| 9.5.5 · Wooldridge Extended Two-Way Mundlak Fixed-Effects DID | wooldridge_etwfe | xthdidregress twfe (y x1) (treat), group(id) | etwfe::etwfe(fml = y ~ x1, tvar = year, gvar = first_treat, data = df, vcov = ~id) | pyfixest.feols('y ~ treat : i(cohort, year) + x1 | id + year', data=df, vcov={'CRV1': 'id'}) | Available |
| 9.5.6 · Clean-Control Local Projections Difference-in-Differences | lp_did | lpdid y, unit(id) time(year) treat(treat) pre_window(4) post_window(6) | fixest::feols(dy_h ~ d_treat + x1 | year, subset = clean_sample, cluster = ~id, data = df) | pyfixest.lpdid(df, yname='y', idname='id', tname='year', gname='first_treat') | Available |
| 9.5.7 · Rambachan-Roth HonestDiD Parallel-Trends Sensitivity | honest_did_sensitivity | honestdid, pre(1/4) post(5/8) mvec(0.5(0.5)2) | HonestDiD::createSensitivityResults_relativeMagnitudes(betahat, sigma, numPrePeriods = 4, numPostPeriods = 4) | scipy.optimize.linprog(c_obj, A_ub=A_rm, b_ub=b_rm) | Available |
| 9.5.8 · Synthetic Difference-in-Differences | synthetic_did | sdid y id year treat, vce(placebo) reps(200) | synthdid::synthdid_estimate(Y, N0, T0) | SynthDID().fit(Y_panel, N0, T0) | Available |
| 9.5.9 · Targeted Maximum Likelihood Estimation van der Laan Rubin | tmle_targeted_mle | teffects aipw (y x1 x2) (treat x1 x2), vce(robust) | tmle::tmle | Clever-covariate targeting step + Efficient Influence Function SE | Available |
| 9.5.10 · Potential Outcomes Causal Mediation ACME and ADE Imai Keele Yamamoto | causal_mediation_imai | mediate (y x1) (m x1) (treat) / sem + estat teffects | mediation::mediate(med.fit, out.fit, treat = 'treat', mediator = 'm') | Sequential ignorability mediator/outcome decomposition + ACME/ADE inference | Available |
| 9.5.11 · Empirical Welfare Maximization and Optimal Policy Tree Kitagawa Tetenov Athey Wager | optimal_policy_tree_kitagawa | teffects ra (y x1 x2) (treat), vce(robust) | policytree::policy_tree + grf::double_robust_scores | Doubly-robust welfare scores + optimal threshold policy rule search | Available |
| 9.5.12 · Heckman Vytlacil Local IV Marginal Treatment Effects | marginal_treatment_effects_mte | mtefe y (treat = z_iv) x1 / teffects ra (y x1) (treat) | ivmte::ivmte / mtefe::mtefe | Local Instrumental Variables polynomial propensity derivative MTE + ATE/ATT integration | Available |
| 9.5.13 · Lee Sharp Nonparametric Sample Selection Treatment Effect Bounds | lee_trimming_bounds | leebounds y treat, cieffect / regress y treat x1, vce(robust) | leebounds::leebounds | Lee (2009) upper/lower quantile-trimmed sharp bounds + Imbens-Manski (2004) CI | Available |
| 9.5.14 · DiNardo Fortin Lemieux Counterfactual Reweighting and Changes in Changes | changes_in_quantiles_dfl_dinardo | dfl treat x1, outcome(y) / teffects ipwra (y x1) (treat x1) | qte::CiC(y ~ treat, t = year, tmin1 = t0, t = t1, data = df) | DiNardo-Fortin-Lemieux propensity-odds reweighting + Athey-Imbens quantile counterfactuals | Available |
| 9.5.15 · Athey Imbens Nuclear Norm Matrix Completion Causal Panel Estimator | matrix_completion_panel_athey | fect y, treat(treat) unit(entity) time(year) cov(x1) method(mc) | fect::fect(y ~ treat + x1, data = df, index = c('entity', 'year'), method = 'mc') | Athey et al. (2021) Singular-Value-Thresholding (SVT) nuclear-norm matrix completion + ATT | Available |
9.5.4. Standard Implementation Workflow for Part 9.5
Step 1. Load Standardized Practice Datasets From VietLOD, EcoData, or Finco
Download the model-specific .csv practice dataset in Part 9.5 or extract custom empirical panels from EcoData and Finco.
Step 2. Select the Optimal Estimator for Your Error and Sample Structure
Compare the estimators from 9.5.1 to 9.5.15 in the syntax matrix above and execute the estimation in Stata 18 MP, R 4.x, or Python 3.11+.
Step 3. Run Mandatory Diagnostics and Export Publication Tables on EcoLab
Verify all required diagnostics including Tổng tỷ trọng và ước lượng DID trung bình theo 3 nhóm, tỷ phần trọng số bị ô nhiễm động học. and dispatch the specification to EcoLab for automated journal-grade reporting.