Announcement

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

  • -sdid- conformability error

    I'm trying to use the user-created "sdid" command for a project. I want to run a placebo check where I assign treatment to every unit in my analysis, however, doing so eventually generates a 3200 conformability error.

    The following code generates the error for me at the 28th iteration of the loop.

    Code:
    * Load data
    webuse set www.damianclarke.net/stata/
    webuse prop99_example.dta, clear
    
    * Convert unit to numeric to loop over
    encode state, gen(state_code)
    
    * Loop over all possible units
    forvalues state = 1/39 {
    
        * Generate placebo treatment
        gen placebo`state' = (state_code == `state' & year >= 1989)
    
        * Run analysis
        sdid packspercapita state year placebo`state', vce(placebo) reps(500)
    }
    Interestingly, decreasing the number of bootstrap replications seems to stave off the error message. With reps(50), I get no error.

    Why is this happening and is there anything I can do about it?

    Any help would be much appreciated!

  • #2
    SDID isn't a thing when all units are eventually treated. At some point, the matrix algebra under the hood makes it impossible. More practically, there's no information to infer the potential outcome from, since there's no control group at this point.

    What you're doing WOULD work, if you reloaded the dataset each time and reassigned the treatment to each unit. But at present, it's literally to the point that every unit is treated! And that's not what you want.


    Also, why are you making 39 treatment variables? Better to just replace treatment if unit = state and year>=1989, else 0 (see the cond function).

    Comment


    • #3
      Thanks Jared!

      I tried re-writing the loop so that it re-loads the data each time, but I still get the 3200 conformability error message. (I now get it at the 37th iteration of the loop.)

      Interestingly, if I manually run the -sdid- command after the conformability error breaks the loop, it works. I'm not sure what would explain this.

      Here is the new code I tried:

      Code:
      * Loop over all possible states
      forvalues state = 1/39 {
          
          * Load data
          webuse set www.damianclarke.net/stata/
          webuse prop99_example.dta, clear
          
          * Encode state
          encode state, gen(state_code)
          
          * Generate placebo
          gen placebo = (state_code == `state' & year >= 1989)
          sdid packspercapita state year placebo, vce(placebo) reps(500)
      }

      Comment

      Working...
      X