Skip to content

SUMM: difference in differences, panel data and similar treatment effects #3631

Open

Description

@josef-pkt

triggered by #3622

DiD in the simplest case is just the interaction effect of time and group dummies in OLS
What support to we need? What extensions and related models would be useful?

asymptotics

  • standard DiD: 2 time periods, T = 2, number of individuals in treated n0`` and control/untreated n0` both go to inf
  • small sample corrections: number of time periods T and number of groups is small, similar to cluster robust cov_type Donald and Lang 2007
  • T small/fixed, n0 (number treaded) small and fixed, n1 -> inf Conley and Taber 2011
  • T (or only pre-treatment periods, T0, goes to inf, n0 (number treaded) small and fixed, panel and time series
    • synthetic control Abadie, et al. 2010 and other years (motivated for case studies with one treated unit)
    • Hsiao, Chin and Wang 2012 (HCW), and followup studies, expecially Li and Bell 2017

methods and approaches

  • basic DiD: fixed effects OLS
  • DiD with IPW: Abadie 2008 (semiparametric) (This looks good for background and for specific application) Cross-sectional IPW with selection on observables is special case.
  • DiD with matching: (I didn't read anything specific) Heckman, Todd and Ichimura, mentioned as comparison case in some newer studies that compare DiD-Matching with sythetic control and HCW
  • synthetic control: matching-weights in pre-treatment, weighted average for potential outcome in treatment periods
  • HCW: very simple to implement, OLS in pre-treatment and prediction of outcome variable in treatment years. uses only outcome variable, important variable selection either AICC/BIC or Lasso and cross-validation
  • estimated factor model: similar to HCW but with estimating the full factor model. Both synthetic control are motivated by factor model structure, but don't use and estimate it explicitly
    • Bai (interactive fixed effects, not looked at, code in Julia),
    • Xu 2017 uses factor model for prediction of potential outcome
  • non-linear: not looked at, e.g. Logit/Probit, ...

Doudchenko, Nikolay, and Guido W. Imbens. (too long to print, not read, but

API and structure

??? eclectic

  • DiD: packages in Stata, wrapper around OLS, adding IPW of difference regression, ... ?
  • synthetic control: packages in Stata, main point estimating the weights.
    No standard errors, testing through placebo tests.
  • HCW: simple OLS but work on variable selection or penalization (limitation if number of pre-treatment periods is not long enough, and there are many potential controls.)

References

(notes:
There are many surveys, lecture notes, slides, summaries, textbook chapters that were not detailed enough for me when I tried in the past for DiD and related methods.
List below is incomplete, mostly the main articles that I looked at)

Abadie, Alberto, Alexis Diamond, and Jens Hainmueller. 2010. “Synthetic Control Methods for Comparative Case Studies: Estimating the Effect of California’s Tobacco Control Program.” Journal of the American Statistical Association 105 (490): 493–505.

———. 2015. “Comparative Politics and the Synthetic Control Method.” American Journal of Political Science 59 (2): 495–510. doi:10.1111/ajps.12116.

Abadie, Alberto, and Javier Gardeazabal. 2003. “The Economic Costs of Conflict: A Case Study of the Basque Country.” The American Economic Review 93 (1): 113–32. doi:10.1257/000282803321455188.

Becker, Martin, and Stefan Klößner. n.d. “Fast and Reliable Computation of Generalized Synthetic Controls.”

Donald, Stephen G, and Kevin Lang. 2007. “Inference with Difference-in-Differences and Other Panel Data.” The Review of Economics and Statistics 89 (2): 221–33. doi:10.1162/rest.89.2.221.

Doudchenko, Nikolay, and Guido W. Imbens. 2016. “Balancing, Regression, Difference-In-Differences and Synthetic Control Methods: A Synthesis.” NBER Working Paper 22791. National Bureau of Economic Research, Inc. https://ideas.repec.org/p/nbr/nberwo/22791.html.

Gardeazabal, Javier, and Ainhoa Vega-Bayo. 2016. “An Empirical Comparison Between the Synthetic Control Method and HSIAO et Al.’s Panel Data Approach to Program Evaluation.” Journal of Applied Econometrics, January, n/a-n/a. doi:10.1002/jae.2557.

Hsiao, Cheng, H. Steve Ching, and Shui Ki Wan. 2012. “A Panel Data Approach for Program Evaluation: Measuring the Benefits of Political and Economic Integration of Hong Kong with Mainland China.” Journal of Applied Econometrics 27 (5): 705–40. doi:10.1002/jae.1230.

Kreif, Noémi, Richard Grieve, Dominik Hangartner, Alex James Turner, Silviya Nikolova, and Matt Sutton. 2016. “Examination of the Synthetic Control Method for Evaluating Health Policies with Multiple Treated Units.” Health Economics 25 (12): 1514–28. doi:10.1002/hec.3258.

Lechner, Michael. 2011. “The Estimation of Causal Effects by Difference-in-Difference Methods.” Foundations and Trends® in Econometrics 4 (3): 165–224. doi:10.1561/0800000014.

Li, Kathleen T., and David R. Bell. 2017. “Estimation of Average Treatment Effects with Panel Data: Asymptotic Theory and Implementation.” Journal of Econometrics 197 (1): 65–75. doi:10.1016/j.jeconom.2016.01.011.

Wang, Huiqiang. 2016. “Estimating the Health Impacts of Food Safety Interventions: Optimal Counterfactual Selections via Information Criteria in Small Samples.” Food Policy 63 (August): 44–52. doi:10.1016/j.foodpol.2016.06.005.

Xu, Yiqing. 2017. “Generalized Synthetic Control Method: Causal Inference with Interactive Fixed Effects Models.” Political Analysis 25 (1): 57–76. doi:10.1017/pan.2016.2.

to get started

I played with simplified synthetic control in an example, and tried out what turned out to be the same HCW

  • HCW: easy, use LASSO or elastic net to avoid overfitting, needs cross-validation or similar
    full best subset selection (of explanatory variables) will be computationally expensive with many controls

  • synthetic control: see ENH: causal/treatment effect with synthetic control #3622 has a few tricky parts,

    • nnls and slsqp seem to work fine, we have basinhopping as global optimizer (because outer optimization loop might have multiple local minima)
    • data handling requires work
    • versions with different constraints imposed, (Doudchenko and Imbens)
      (aside: in a simple example without much noise imposing the full no-extrapolation restriction resulted in a single match, i.e. weight=1 for one control and zero for others. This didn't happen without sum to 1 constraint on weights/regression coefficients)
  • support for explicit or implicit matching: covariance balance

  • DiD with IPW: this looks mostly like an extension of the IPW method (Abadie 2005),

    • extension for semi-nonparametric propensity score estimation.
  • extra support for standard fixed effects DiD ???

  • extensions: Xu and factor models look interesting, but data requirements might be too large.
    (Also factor models on untreated as unsupervised component selection might miss features/components that are closer to the controls, i.e. takes common factor structure more literal that synthetic control or HCW.)

Activity

  1. josef-pkt commented on May 8, 2017

    @josef-pkt
    MemberAuthor

    Also for longer time series we can model the time series process additional to the cross-sectional effect from the controls. see Google's CausalImpact.
    Brodersen, Kay H., Fabian Gallusser, Jim Koehler, Nicolas Remy, and Steven L. Scott. 2015. “Inferring Causal Impact Using Bayesian Structural Time-Series Models.” The Annals of Applied Statistics 9 (1): 247–74. doi:10.1214/14-AOAS788.

    and some experiments with SARIMAX in a notebook https://gist.github.com/josef-pkt/a8e8181096a7a06a1413fe3d84f9a56d

  2. josef-pkt commented on May 8, 2017

    @josef-pkt
    MemberAuthor

    variable selection or penalization parameter choice is still open see #3647 for PR for basic setup

    one idea for cross-validation:
    The way I have seen so far is to split the pre-treatment periods to estimate on one part and cross-validate on the left-out pre-treatment sample.
    However, in analogy to the permutation, cross-sectional placebo tests, we could assume exchangeability and do the specification search by predicting other units, i.e. controls. This should work for regularization parameters such as the penalization weights in LASSO or elastic net, but would not work directly for choosing variables, i.e. neighbors, because the match would be unit specific.
    This would create more opportunities for cross-validation in the small-T case.

    Related: Doudchenko and Imbens mention to use a Poisson prior on the number of controls in the predictive regression, with poisson mean equal to 3. Sounds like an interesting idea, but I don't see a computational or theoretical advantage to, for example, AICc, which has a justification in terms of Kullback-Leibler distance.
    One advantage is that using a poisson prior has more flexibility in that we can choose interpretable parameters, and we could do standard penalization search for example by cross-validation.
    (The mechanics are not quite clear to me how a poisson prior affects variable selection, e.g. compared to a L0 prior/penalization.)

  3. josef-pkt commented on May 9, 2017

    @josef-pkt
    MemberAuthor

    proposal: class for basic DiffInDiff in statsmodels.treatment.panel_effect
    I guess it would mainly be interesting as a convenience class to bring various methods together for the specific analysis.
    The treatment folder will be partially more like stats with specific targets like ATT, ATE and specific model assumptions instead of providing general purpose models like the other Models.

    __init__ needs to include several data arrays, maybe in long form with groups and treatment as extras (or treatment as exog)
    fit maybe best if it would default to cluster robust (possible: use cluster as shortcut keyword for cov_type='cluster', cov_kwds={'groups': cluster} to save on typing and as reminder in the signature. with explicit cov_type used to override it.

    The method option might become a bit messy, if we want to include matching and IPW options.

    example for Stata:
    Villa, J. M. 2016. “Diff: Simplifying the Estimation of Difference-in-Differences Treatment Effects.” Stata Journal 16 (1): 52–71.
    which I don't have access to. there is a 2012 working paper that mainly has examples and no explanations or formulas for the methods
    https://ideas.repec.org/c/boc/bocode/s457083.html

  4. josef-pkt commented on Oct 1, 2023

    @josef-pkt
    MemberAuthor

    recent developments for diff in diff

    de Chaisemartin, Clément, and Xavier D’Haultfœuille. “Two-Way Fixed Effects and Differences-in-Differences with Heterogeneous Treatment Effects: A Survey.” The Econometrics Journal 26, no. 3 (September 1, 2023): C1–30. https://doi.org/10.1093/ectj/utac017.

    Roth, Jonathan, Pedro H. C. Sant’Anna, Alyssa Bilinski, and John Poe. “What’s Trending in Difference-in-Differences? A Synthesis of the Recent Econometrics Literature.” Journal of Econometrics 235, no. 2 (August 1, 2023): 2218–44. https://doi.org/10.1016/j.jeconom.2023.03.008.

    Wooldridge, Jeffrey M. “Simple Approaches to Nonlinear Difference-in-Differences with Panel Data.” The Econometrics Journal 26, no. 3 (September 1, 2023): C31–66. https://doi.org/10.1093/ectj/utad016.

    Wooldridge, Jeffrey M. “Two-Way Fixed Effects, the Two-Way Mundlak Regression, and Difference-in-Differences Estimators.” SSRN Scholarly Paper. Rochester, NY, August 17, 2021. https://doi.org/10.2139/ssrn.3906345.

    We need an outline of what we could add that is not just a basic dummy interaction effect in OLS or similar.

  5. josef-pkt commented on Jul 24, 2025

    @josef-pkt
    MemberAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions