Bartik instrument exploration in R

Paul Goldsmith-Pinkham and co-authors have a nice paper on “shift share” or Bartik instruments that I’m working my way through. Whenever I’m doing some econometric exploration, I like to create a simulation where I “know” the right answer and confirm I can recover it with the method. I was doing this for the Bartik instrument and thought other people might find it useful to see a simple example.

And here we have the results—the biased OLS in the left column, and the IV estimate in the right column. We can see that w/ our 1,000 example, we can recover the correct supply elasticity (in the code, I passed an elasticity of labor supply of 1).