Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • TWFE DiD with time varying covariates

    I want to estimate the effect of d on y using a simple 2x2 DiD model with a balanced panel (I observe treatment and control group before and after treatment). I suspect that parallel trends are more plausible conditional of a time-varying covariate X, so I want to control for this. Running a TWFE regression (equation 1) with individual and time fixed effects and an indicator D equal to one when the treatment group is in the second period yields very different results than the "classical" implementation (equation 2). Without X, the results are the same. I know that time-varying covariates can be a problem if they affect treatment or vice versa, but independently, does anyone know or can explain why the estimation of D_it and treat*post are not the same? (In my case, the TWFE estimate is 10 times larger). I haven't found an explanation and I can't wrap my head around it

    xtreg y i.individual + i.time + i.d + X, vce(cluster i.individual) (1)
    xtreg y i.treat + i.post +(i.treat*i.post) + X, vce(cluster i.individual) (2)

  • #2
    When you adjust for a new confounding predictor, why wouldn't we expect the results to change?

    Also
    Code:
    i.treat + i.post +(i.treat*i.post)
    Should just be D (no need to add the interaction)

    and the other regression should be
    Code:
    reg y i.treat##i.post
    the code you now have uses random effects.

    Comment


    • #3
      Originally posted by Jared Greathouse View Post
      When you adjust for a new confounding predictor, why wouldn't we expect the results to change?
      In both specifications I adjusted for the same confounding predictor X so I dont really understand why the results are different. As far as I understand, in a simple 2x2 DiD, TWFE and the classic DiD with an interaction should be the same. Sorry for writing the wrong code, I tried to adjust to my code from R. The code I meant is (which produces the results):
      xtreg y i.individual i.time D X, fe vce(cluster i.individual) (1) xtreg y treat##post X, vce(cluster i.individual) (2)

      Comment


      • #4
        Jared is absolutely right, and you should add "fe" after the comma (and remove i.individual) or just run pooled ols (with reg) and use the FWL (1933) theorem for equivalence of LSDV and FE results.

        You may want to check Zeldow and Hatfield (2021) on the dangers of adding time-varying confounders in DiD (it is not always a good idea).

        But also, if a confounder changes your results, this indicates that the variation in treatment that you are exploiting is not plausibly exogenous, casting doubt on your identification strategy... could you give us more details on your research question?

        Comment


        • #5
          The interesting article Maxence points us out to can be downloaded for free from:https://www.ncbi.nlm.nih.gov/pmc/articles/PMC8522571/.
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment


          • #6
            Thanks to all for the help and the article! I would like to estimate the impact of building wind farms in municipalities on the electoral results of pre renewable parties. My covariate is population per municipality, which varies for each municipality. If I assume that the effect of population is constant over time and that population change is not affected by treatment, I thought that controlling for this should be fine.
            My question is why the coefficient on the treatment indicator is different for a model with a time dummy and a group dummy when I include population and a model that replaces the group dummy with individual fixed effects, while it is the same for both specifications when I control for a time invariant variable (I have 2 periods and a balanced panel).

            Comment


            • #7
              Vincent:
              with no more details on your data, that you can easily share via -dataex-, it is difficult to reply positively.
              That said, according to your codes, you're not going TWFE.
              If TWFE is your methodological approach, your codes should be:
              Code:
              xtset individual year
              xtreg y  i.time  i.d  X, fe vce(cluster i.individual)
              xtreg y i.treat## i.post  X, fe vce(cluster i.individual)
              Kind regards,
              Carlo
              (Stata 19.0)

              Comment

              Working...
              X