Announcement

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

  • Difference-in-difference parallel trend graph time dummies all omitted after adding time fixed effects

    Hello,

    I am new to the forums but have read some posts on the forums which have helped me. So thank you for your previous help.

    I am working on a dataset of job-month records, and my panel data is organized by job-year-month-company-job performance.

    I have a shock during this period. So I calculated a variable called gap to denote the month difference from the current month to the shock month, from -5 to 5.

    Now I want to plot the parallel trend graph to see if it holds the parallel trend assumption. I used two-way fixed effects of company and year month.

    I used the following code:
    Code:
    eventdd job_performance , timevar(gap) method (hdfe, absorb(company year month ) vce(cluster company)) accum leads(5) lags(5) baseline(-1) noline coef_op(m(oh) c(L) color(black) lcolor(black)) graph_op(ytitle("Parallel Trend") color(black) xline(0, lc(black*0.5) lp(dash)) graphregion(fcolor(white)))
    However, all my time dummies, from -5 to 5, are omitted.

    I also tried to estimate the coefficient for DID using the following codes:
    Code:
    gen post = 0
    replace post = 1 if gap > 0
    
    gen treat = 1 if country == "shocked_areas"
    replace treat = 0 if treat == .
    
    reghdfe job_performance did $controllist, absorb(company year month) vce(cluster company)
    The did variable is omitted.
    Code:
    (MWFE estimator converged in 3 iterations)
    note: did is probably collinear with the fixed effects (all partialled-out values are close to zero; tol = 1.0e-09)
    Is there anything I did wrong? What is the problem here?

    Best,
    Tong
    Last edited by Tong Xu; 03 Dec 2024, 22:24.

  • #2
    Yes, has told you what went wrong. Stata said: did is probably collinear with the fixed effects. In particular, the variable gap is colinear with post. So you cannot have both of them in the model. This problem arises any time you have a DID design where the treated group are all exposed at the same time. Keep gap and leave out the time fixed effects and all will be fine.

    Using two-way fixed effects for a DID is only needed (and only possible) when the onset of treatment differs across the units in the exposed group. But in that case, you also would not use the variable gap in the analysis either--you would use only the treat#gap interaction plus the two-way fixed effects.
    Last edited by Clyde Schechter; 03 Dec 2024, 22:37.

    Comment


    • #3
      Originally posted by Clyde Schechter View Post
      Yes, has told you what went wrong. Stata said: did is probably collinear with the fixed effects. In particular, the variable gap is colinear with post. So you cannot have both of them in the model. This problem arises any time you have a DID design where the treated group are all exposed at the same time. Keep gap and leave out the time fixed effects and all will be fine.

      Using two-way fixed effects for a DID is only needed (and only possible) when the onset of treatment differs across the units in the exposed group. But in that case, you also would not use the variable gap in the analysis either--you would use only the treat#gap interaction plus the two-way fixed effects.
      Thank you for your reply!

      I tried
      Code:
      eventdd job_performance $controllist, timevar(gap) method (hdfe, absorb( company ) vce(cluster company)) accum leads(6) lags(5) baseline(-1) noline coef_op(m(oh) c(L) color(black) lcolor(black)) graph_op(ytitle("Parallel Trend") color(black) xline(0, lc(black*0.5) lp(dash)) graphregion(fcolor(white)))
      and
      Code:
      reghdfe job_performance did $controllist, absorb( company ) vce(cluster company)
      and these codes gave me results.

      Comment


      • #4
        I have a further question.

        Since previously I was thinking of using twfe-did, so I did not include the treat and post variable in the regression.

        Right now, I learned that because I have the treated group all exposed at the same time, I cannot have time fixed effects.

        So do I need to add back treat and post variable and let the code be the following?

        Code:
         
         reghdfe job_performance treat post did $controllist, absorb( company ) vce(cluster company)
        Since I still have the company fixed effects, then the treat variable will be omitted. So do I need to add back the post variable?

        Comment


        • #5
          The general principle that rules in all applications is: you cannot have colinear variables in the same model. This means that you cannot have both treat and company fixed effects. It means that you cannot have both post and time fixed effects.

          Your situation is actually the simplest possible DID analysis: you have a single shock occurring at one time. There are at least two different ways you can code this and they will all produce the same results for the effect of the shock:
          Code:
          regress job_performance i.treat##i.post $controllist, vce(cluster company) // NOTE: -regress-, NOT ONE OF THE FE COMMANDS; ALSO NOTE ##, NOT #
          // OR
          reghdfe job_performance i.treat#i.post $controllist, vce(cluster company) absorb(company time) // NOTE #, NOT ##; THIS IS A TWFE MODEL
          To understand these alternatives, bear in mind that your did variable is equivalent to -treat#post- and that -treat##post- is equivalent to -treat post treat#post-.

          If you mistakenly include a time or treatment fixed effect when it is not needed, Stata will recognize this and will remove it (or will remove something else that it is colinear with). While this is aesthetically unappealing and probably not the way you want to show results to others, bear in mind that the results you get for the DID estimation of the shock effect will still be correct, they will be the same as you would have gotten from correctly specifying the model.

          Comment


          • #6
            Thank you so much, Clyde!

            Comment

            Working...
            X