grantmcdermott / etwfe

Extended two-way fixed effects
https://grantmcdermott.com/etwfe/
Other
50 stars 11 forks source link

gvar variable question #12

Closed OscarAndresMartinez closed 1 year ago

OscarAndresMartinez commented 1 year ago

Dear Professor Greetings, I've been reading your etwfe code but I'm having a little problem with the gvar variable, my treatment is cumulative percentage km2 of protected areas (percentacumestricta) and outcome (RLI) these variables are continuous and I have data from 2000 to 2014 by country (ID) -year (t).

treated=1 if percentacumestricta >17

I created gvar variable: bysort ID: egen min_year=min(year) if treated==1 bysort ID: egen First_treated=max(min_year) replace First_treated=0 if First_treated==. tab year First_treated

However I couldn´t understand how you create your gvar, Could you explain me that please?

I really appreciate your comments Thanks for your time All the best

grantmcdermott commented 1 year ago

Hi Oscar,

  1. It looks like you've got Stata code rather than R code here. In that case you probably want to try jwdid instead of etwfe. See Fernando's thorough walkthrough here: https://friosavila.github.io/playingwithstata/drdid/jwdid_stata.html
  2. For the mpdta dataset that I use in the examples, the gvar variable("first.treat") was already created by the dataset authors. There's not enough information to create it from the other columns.

Closing, but feel free to reply if you're still stuck.