I'm trying to do a synthetic control analysis with multiple treated units and treatment timings. I have decennial county data from 1970 to 2010, and treatment is at the county level. Below is the code I run to make it panel data:
tsset uniqueid year, yearly delta(10)
It tells me that the data is strongly balanced, so there shouldn't be any issues there.
Below is a simplified example of the structure of my data:
This is very simplified as my actual dataset has 184 variables, but none of the variables that I plan on using as either outcomes or predictors have any missing values. This is one example I've tried running from allsynth:
allsynth log_med_house_value log_med_house_value(1970) log_med_house_value(1980) log_med_house_value(1990), transform(log_med_house_value, normalize) bcorrect(merge) keep(Results, replace) stacked(trunits(treat) trperiods(treat_year), clear eventtime(-3 1) figure(classic bcorrect, save(Results/ate, replace) xtitle(Year relative to treatment)))
It returns the error:
"control units: for at least one unit, predictor log_med_house_value(1970_ is missing for ALL periods specified"
This clearly isn't the case in my data. I also don't know why in the error the closing parenthesis is shown as an underscore, but I checked my code and I did indeed close the parentheses. Is allsynth somehow not reading my data correctly since it's decennial instead of annual? I've tried other outcomes and predictors and I get the same error for every variable I've tried. Before using allsynth I was using synth_runner and the same was happening with that. Any help would be really appreciated!
In addition to that issue, I was wondering how I can make the years for the predictors differ depending on the treatment timing with allsynth. With synth_runner it seemed I could do something like below:
program my_pred, rclass
args tyear
return local preds "log_med_house_value(`=`tyear'-30'(10)`=`tyear'-10') totalpop(`=`tyear'-30'(10)`=`tyear'-10')"
end
I would then use pred_prog(my_pred) as an option in synth_runner. Is there a way to do something similar in allsynth? I haven't found a way. Thanks in advance for any help with either issue!
tsset uniqueid year, yearly delta(10)
It tells me that the data is strongly balanced, so there shouldn't be any issues there.
Below is a simplified example of the structure of my data:
year | state | county | log_med_house_value | treat | treat_year |
1970 | 01 | 001 | 10.5 | 0 | . |
1980 | 01 | 001 | 10.6 | 0 | . |
1990 | 01 | 001 | 10.7 | 0 | . |
2000 | 01 | 001 | 10.8 | 0 | . |
2010 | 01 | 001 | 10.8 | 0 | . |
1970 | 03 | 012 | 10.1 | 1 | 2000 |
1980 | 03 | 012 | 10.1 | 1 | 2000 |
1990 | 03 | 012 | 10.3 | 1 | 2000 |
2000 | 03 | 012 | 10.5 | 1 | 2000 |
2010 | 03 | 012 | 10.5 | 1 | 2000 |
1970 | 10 | 003 | 11.1 | 0 | . |
1980 | 10 | 003 | 11.4 | 0 | . |
1990 | 10 | 003 | 11.4 | 0 | . |
2000 | 10 | 003 | 11.5 | 0 | . |
2010 | 10 | 003 | 11.3 | 0 | . |
1970 | 24 | 092 | 10.9 | 1 | 2010 |
1980 | 24 | 092 | 11.1 | 1 | 2010 |
1990 | 24 | 092 | 11.2 | 1 | 2010 |
2000 | 24 | 092 | 11.2 | 1 | 2010 |
2010 | 24 | 092 | 11.1 | 1 | 2010 |
allsynth log_med_house_value log_med_house_value(1970) log_med_house_value(1980) log_med_house_value(1990), transform(log_med_house_value, normalize) bcorrect(merge) keep(Results, replace) stacked(trunits(treat) trperiods(treat_year), clear eventtime(-3 1) figure(classic bcorrect, save(Results/ate, replace) xtitle(Year relative to treatment)))
It returns the error:
"control units: for at least one unit, predictor log_med_house_value(1970_ is missing for ALL periods specified"
This clearly isn't the case in my data. I also don't know why in the error the closing parenthesis is shown as an underscore, but I checked my code and I did indeed close the parentheses. Is allsynth somehow not reading my data correctly since it's decennial instead of annual? I've tried other outcomes and predictors and I get the same error for every variable I've tried. Before using allsynth I was using synth_runner and the same was happening with that. Any help would be really appreciated!
In addition to that issue, I was wondering how I can make the years for the predictors differ depending on the treatment timing with allsynth. With synth_runner it seemed I could do something like below:
program my_pred, rclass
args tyear
return local preds "log_med_house_value(`=`tyear'-30'(10)`=`tyear'-10') totalpop(`=`tyear'-30'(10)`=`tyear'-10')"
end
I would then use pred_prog(my_pred) as an option in synth_runner. Is there a way to do something similar in allsynth? I haven't found a way. Thanks in advance for any help with either issue!
Comment