Announcement

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

  • Aligning years to the first implementation year

    Hello all,

    I have a slightly complicated question but I'll try my best to explain it. The thing is that I want to align all intervention (treatment) active years to the first year, say 2001.
    My intervention values vary by state and year starting from 2001 to 2018. For example, Georgia is active from 2005 to 2018 and Florida is active from 2001 to 2018.
    (All the variables I have is state id, year, treatment, and the outcome variable)
    However, I wanted to align them to the first year: 2001, which means that all interventions are assumed to start from 2001.
    May I ask which commands I can use?

    Thank you for your help in advance.






  • #2
    Create a new variable and name it "time", counting from 1. Otherwise, your suggestion would be misleading. Assuming that your treatment variable is binary 0/1.

    Code:
    bys state_id treatment (year): gen time=_n if treatment

    Comment


    • #3
      It likely doesn't matter, but I adopt a slightly different way of doing things. Suppose we have two treated units, one whose treatment begins in 2005 and the other in 2008. I'll do

      Code:
      g relative = .
      
      qui levelsof ID if treated, l(trunits)
      
      qui foreach x of loc trunits {
      
      su date if ID ==`x'
      
      loc tbegin = r(min)
      
      replace relative = date- `tbegin' if ID ==`x'
      }
      this means that your intervention begins at time 0, all the way until the end of the time series, and is -1, -2... until the beginning of the time series, for all treated units. So for unit 1, 0 corresponds to 2005, and for the next one, 0 corresponds to 2008.

      If for some reason, I wanted to keep only the post-intervention data, I'd just keep if rel> -1

      and boom, all treated units and their post intervention data right there.

      Comment

      Working...
      X