Hello,

i am trying to run a placebo test with the synth command downloaded from the homepage of Jens Hainmüller (Welcome to the Webpage of Jens Hainmueller (stanford.edu)

I have looked through old forums and there i could find basically the solution for creating the code.

My data set is a panel data set with yearly information on the Total Home Equity Loans and Total First Purchase Loans and a identifier for each state from the HMDA Data Set for each state.

Therefore i want to do a Placobo Test for one single State in 1998.

My Code:


tsset id year

forval i = 1/60 {

qui synth logRefstate logFPstate StateNumberHEL StateNumberFP logRefstate(1996), trunit(`i') trperiod(1998) keep(synth_`i', replace)
}

forval i = 1/60{

use synth_`i', clear

rename _time years

gen tr_effect_`i' = _Y_treated - _Y_synthetic

keep years tr_effect_`i'

drop if missing(years)

save synth_`i', replace
}
use synth_1, clear

forval i=2/60{

qui merge 1:1 years using synth_`i', nogenerate
}

local lp

forval i=1/60 {
local lp `lp' line tr_effect_`i' years, lcolor(gs12) ||
}
*
* create plot

twoway `lp' || line tr_effect_3 years, ///
lcolor(orange) legend(off) xline(1998, lpattern(dash))


My problem is that in the second line i receive the error message: treated unit not found in panelvar - check tr()

And it works if add one number betweeen 1-60 for the trunit() command. I don´t know why stata can´t find my identifier, it has to be a problem with the `i' within the trunit(`i') command.

If i run the code for example with trunit(1) it created 60 treatment effects but shows only the one for id 1, so the code works, i just don´t understand why the first loop doesn´t recognize the treatment unit.

Currently i am using Stata 16.1 - on the webpage of MR. Hainmüller there is written that the synth command works for Stata 9-15, but for my Synthtic Analysis it has also worked so i don´t know if Stata is Problem.

Thank you in advance.