Announcement

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

  • Time fixed effect in difference-in-difference

    I am currently using a difference-in-differences model to study the impact of an event on 367 stocks.
    I use treat to distinguish the treatment group from the control group.
    Set time dummy variable:
    Code:
    gen after = (date >= td(01feb2021))
    I then used the following code to run the did model, controlling for time fixed effects. Normally, the time dummy variable should be absorbed by the time fixed effect, but why does my after variable coefficient still have a value?

    Code:
    encode ticker_f, generate(ticker_f2)
    encode created_day, generate(created_day2)
    xtset  ticker_f2 created_day2
    xtreg y i.after##i.treated i.created_day2, fe vce(robust)
    y | Coefficient std. err. t P>|t| [95% conf. interval]
    -------------- +----------------------------------------------------------------
    1.after | -32.94548 6.969544 -4.73 0.000 -46.65085 -19.2401
    1.treated | 0 (omitted)
    |
    after#treated |
    1 1 | -8.712043 4.413733 -1.97 0.049 -17.3915 -.0325843


    I hope anyone can give me some advice, I will be very grateful.

  • #2
    Xiurui:
    welcome to this forum.
    In your code, the -fe- relates to -ticker_f-, not to -timevar-.
    You could expect colinearity issue between -after- and -i.created_day2- at worst, but it did not happen.
    For the future, please use CODE delmiters to share what you typed and what Stata gave you back and provide an example/excerpt of your data via -dataex- (both these topics are covered in the FAQ). Thanks.
    Finally, you may want to consider -didregress- and -xtdidregress- for what you're after.
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Originally posted by Carlo Lazzaro View Post
      Xiurui:
      welcome to this forum.
      In your code, the -fe- relates to -ticker_f-, not to -timevar-.
      You could expect colinearity issue between -after- and -i.created_day2- at worst, but it did not happen.
      For the future, please use CODE delmiters to share what you typed and what Stata gave you back and provide an example/excerpt of your data via -dataex- (both these topics are covered in the FAQ). Thanks.
      Finally, you may want to consider -didregress- and -xtdidregress- for what you're after.
      Thank you very much for your reply! I will post in a more standard format from now on, thank you for the suggestion.
      I referred to other people's codes for controlling time fixed effects. My understanding is that -fe- controls individual fixed effects (ticker), and -i.created_day2 controls time fixed effects. I don’t know if this is correct. Is there any more appropriate way to control time fixed effects?
      I'll try using -didregress- and -xtdidregress- in the future, thanks for the advice. I'm still trying to figure out why xtreg is having such problems, so if you have any ideas in the future please send them to me.

      Comment


      • #4
        Xiurui:
        if you want to retrieve the time fixed effect too, you shouls switch to the community-contributed module -reghdfe- (just type -search reghdfe- from within Stata and follow the instriction to install it).
        Kind regards,
        Carlo
        (StataNow 18.5)

        Comment


        • #5
          Originally posted by Carlo Lazzaro View Post
          Xiurui:
          if you want to retrieve the time fixed effect too, you shouls switch to the community-contributed module -reghdfe- (just type -search reghdfe- from within Stata and follow the instriction to install it).
          Thank you very much for your help, I will try the method you gave.

          Comment

          Working...
          X