Announcement

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

  • Diff-in-Diff using -xtreg- & -reghdfe-

    Consider a panel data where -gvkey- is the panel identifier and -fyear- is the time variable in the panel.

    Suppose the following treatment occurs at the industry level

    Code:
    gen assignment=0
    replace assignment =1 if (industry == 101 | industry == 102)
    g period = 0
    replace period = 1 if fyear >= 2020
    g treatment = period * assignment
    
    
    g two_before =.
    replace two_before=1 if fyear==2018
    replace two_before=1 if fyear==2019
    replace two_before=1 if fyear==2020
    gen D_before = sum(two_before), by (gvkey)
    g two_after =.
    replace two_before=1 if fyear==2021
    replace two_before=1 if fyear==2022
    replace two_before=1 if fyear==2023
    gen D_after = sum(two_after), by (gvkey)
    The policy change occurred in 2020.

    Code:
    gen period = 0
    replace period = 1 if fyear>=2020
    I test the following three diff-in-diff using -reghdfe- and -xtreg-:

    Specification #1:
    Code:
    reghdge y i.treatment i.fyear if ( fyear>=2018 & fyear<=2022) & (industry == 101 | industry == 102) & D_before>=2 & D_after>=2, absorb(gvkey) cluster(gvkey)
    Specification #2:
    Code:
    reghdfe y i.treatment i.fyear, absorb(gvkey fyear) cluster (gvkey)
    Specification #3:
    Code:
    xtreg y i.treatment i.fyear, fe vce(cluster gvkey)


    My questions:

    (1) How are these three specifications different?

    (2) I am getting similar coefficients for #2 and 3 but completely different coefficient for #1. Why is this the case?

    (3) Which is the correct diff-in-diff specification?

  • #2
    Stephen:
    (1) and (2): Specifications #2 and #3 are equivalent, while the first one -absorb()- the -panelvar- only + many -if- qualifiers that I do not folllow;
    (3): to make DID works, you should have: treatment (yes/no) groups; time of a given event (before/after). That said, why not considering -help didregress-?
    See also Joshua Angrist's tutorial on DID at https://www.youtube.com/watch?v=eiffOVbYvNc
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Hi Carlo,

      Thanks for the reply.

      I suspect #1 is a wrong specification for DID.

      Yes, I have read the manual for the commands -xtdidregress- or -didregress-.

      I believe #2 and 3 would be identical to the following -xtdidregress- command, would you agree:

      Code:
       xtdidregress (y) (treatment), group(gvkey) time(fyear)
      Originally posted by Carlo Lazzaro View Post
      Stephen:
      (1) and (2): Specifications #2 and #3 are equivalent, while the first one -absorb()- the -panelvar- only + many -if- qualifiers that I do not folllow;
      (3): to make DID works, you should have: treatment (yes/no) groups; time of a given event (before/after). That said, why not considering -help didregress-?
      See also Joshua Angrist's tutorial on DID at https://www.youtube.com/watch?v=eiffOVbYvNc

      Comment


      • #4
        Stephen:
        Have you tried them out?
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Carlo,

          Yes, the -xtdidreg- results are same as the ones in -reghdfe- and -xtreg, fe-!

          But it seems to have time-varying treatment assignment issues, which doesn't make sense to me given the identification strategy I have.


          Originally posted by Carlo Lazzaro View Post
          Stephen:
          Have you tried them out?

          Comment

          Working...
          X