Announcement

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

  • Generating an Event Study Graph

    Hello,

    I have balanced panel data of States in the Time 0-10, an outcome variable Y, and a treatment variable Treat. A shock hits all states in Time=5. I want to estimate the effect of the shock interacted with Treat.
    To do that I estimate the following Two-Way-Fixed-Effect Event-Study specification:

    Code:
    xtset State
    xtreg Y b4.Time##c.Treat, fe robust
    I want to present the results graphically. On the X-axis there should be Time 0-10. On the Y-axis there should be the coefficients of the Interaction of Treat and each Year dummy, with the corresponding confidence interval.

    I am unsure how I can create this plot. My main problem is that I do not know how to extract and store the coefficients and CIs of the interaction variables.

    I would very much appreciate help with this.
    Thank you very much.

  • #2
    Code:
    ssc install coefplot, replace
    Code:
    webuse grunfeld, clear
    xtset company time
    xtreg invest ib20.time##c.mvalue, fe robust
    set scheme s1mono
    coefplot ., keep(*.time#c.mvalue) xlab(1/19) vert  ytitle(Coefficient)
    Res.:

    Click image for larger version

Name:	Graph.png
Views:	1
Size:	22.5 KB
ID:	1722269


    Comment


    • #3
      Thank you very much, that is very helpful!
      Just two issues arise.
      1. The coefficient for Time 4 (the baseline) is dropped, though I would like to include it as coefficient = 0 (with no CI). Can I do this?
      2. Relatedly, I would like to add a vertical line at Time 5, signifying the start of the shock. Could I do this?

      Thank you very much again.

      Comment


      • #4
        The vertical line will interfere with the CI on T=5, but here is how you would do it:

        Code:
        webuse grunfeld, clear
        keep if time<11
        xtset company time
        xtreg invest ib4.time##c.mvalue, fe robust
        set scheme s1mono
        coefplot ., baselevels omitted xline(5) keep(*.time#c.mvalue) xlab(1/10) vert  ytitle(Coefficient)
        Click image for larger version

Name:	Graph.png
Views:	1
Size:	20.3 KB
ID:	1722277

        Comment


        • #5
          Thank you so much, the omitted coefficient shows perfectly now.

          However, the vertical line still does not appear. I think it is because the coefficient is not of Time=5, but rather the interaction of Time=5 with the c.Treat.
          But when I try to replace xline(5) with xline(5.Time#c.Treat) I still get an error message.

          Thank you again.

          Comment


          • #6
            As far as I know, 5 represents the position of the coefficient in the graph. So in my graph, the base is at position 4 and T=5 is at position 5. You will have to present a reproducible example if you are not able to make progress. Also, make sure you have the most up to date version of coefplot.

            Comment


            • #7
              Andrew, thank you so much, I was now able to include the xline with no problem.
              A final question if I may, can I rename the variables at the X axis? Namely, instead of seeing time#treat, I would just like to see the time at the x-axis.

              Comment


              • #8
                Code:
                webuse grunfeld, clear
                keep if time<11
                xtset company time
                xtreg invest ib4.time##c.mvalue, fe robust
                set scheme s1mono
                coefplot ., baselevels omitted keep(*.time#c.mvalue)  xtitle(Coefficient)  rename(#c.mvalue = \1, regex)
                *OR
                coefplot ., baselevels omitted keep(*.time#c.mvalue)  xtitle(Coefficient)  rename(.time#c.mvalue = \1, regex)
                Last edited by Andrew Musau; 30 Jul 2023, 07:03.

                Comment


                • #9
                  Dear Andrew Musau, would you mind helping me with a similar issue? I am running the following model:

                  HTML Code:
                  xtreg tarifa treat##treated treat treated, fe robust cluster(id)
                  I want to obtain the value of the interaction by year (ano, in my dataset). Thus, I would have to run something like this:

                  HTML Code:
                  coefplot ., keep(*.ano#treat#treated) xlab(1/12) vert  ytitle(Coefficient)
                  But I keep getting the following error message:

                  HTML Code:
                  . coefplot ., keep(*.ano#treat#treated) xlab(1/12) vert  ytitle(Coefficient)
                  (.: no coefficients found, all dropped, or none kept)
                  (nothing to plot)




                  Comment


                  • #10
                    You don't have a variable "ano" in the regression that you show. Instead of "treat" and "treated", define one indicator "treatment" = 1 if unit \(i\) at time \(t\) was subject to the treatment, and zero otherwise. Then you can interact this indicator with your time variable.


                    Code:
                    xtreg tarifa c.treatment##i.ano, fe robust cluster(id)
                    Last edited by Andrew Musau; 29 Nov 2023, 02:53.

                    Comment


                    • #11
                      Thanks! It worked.

                      Comment

                      Working...
                      X