Announcement

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

  • Diff in diff with event study

    Hello, I am new to the forum and to stata. I have a problem with a diff in diff analysis of an event study. I measured air quality for 3 different cities and have data from 1.1.2018. City A got a treatment on 1.06.2018, and has 15 stations in total and 5 treated. City B got the same treatment at 1.6.2019, and has 4 stations with 3 treated stations. City C was not treated. Do you know how I can run this?
    I tried it with this Code: "csdid NO2, ivar(Stationcode) time(date) gvar(treated) method(dripw) wboot rseed(1)"
    NO2 is my main variable, Stationcode is the number of each station, the date variable is in Stata written like this: "01mar2018" and the treated variable is either 1 or 0, 1 for treated and 0 for untreated.
    I receive the error code:
    "Gvar max value is 1 and there are no periods available before that treatment
    Verify that Gvar is correctly defined
    request may not be combined with by
    r(190);"

    What is wrong with my Code?

    I hope you can help me.

    Best wishes and many thanks in advance
    Tuck

  • #2
    I think gvar is time since treated not just a dummy. not sure about to handle the different number of stations.

    Comment


    • #3
      Thank you for your response. Now I worked on it and runed this code:
      . csdid NO2 , ivar (Stationcode) time(date) gvar(first_treated) method(dripw)

      Units always treated found. These will be ignored

      The problem I have is i my way of thinking the fact I have the start date of 01.06.2018, 01.06.2019 and 01.01.1960.
      I received the 01.01.1960 with this code: . replace first_treat = 0 if missing(first_treat)

      How can I really get 0 as a number for the untreated in my variable "first_treat" like it is in the Dataset when you use "help csdid"?

      Comment


      • #4
        cityC should have no treatment. first_treat==0 for all periods. why start date in 1960? It's a never start date.



        Comment


        • #5
          Dear DSMG
          perhaps you can use :
          egen gvar = csgvar(treated), ivar(Stationcode) tvar(date)

          Also, make sure "DATE" is equally spaced. Otherwise, you wont be able to estimate any effects
          F

          Comment

          Working...
          X