Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ssc install synth
- ipolate educ year, gen(educ2) epolate by(countrycode)
- clear
- cd "C:\Users\Mandlenkosi Sibanda\Documents\Synth2"
- use "data\sanctions.dta"
- tsset countrycode year, year
- #delimit;
- synth gdp
- fdi(1997) gdp(1990) gdp(1999) inflation(1997) educ2(1998) trade2(1999)
- ,
- trunit(40) trperiod(2001) unitnames(country)
- mspeperiod(1990(1)2001) resultsperiod(1990(1)2017)
- keep(data\synth\synth_sanctions.dta) replace fig;
- mat list e(V_matrix);
- #delimit cr
- * Plot the gap in predicted error
- use data\synth\synth_sanctions.dta, clear
- keep _Y_treated _Y_synthetic _time
- drop if _time==.
- rename _time year
- rename _Y_treated treat
- rename _Y_synthetic counterfact
- gen gap40=treat-counterfact
- sort year
- twoway (line gap40 year,lp(solid)lw(vthin)lcolor(black)), yline(0, lpattern(shortdash) lcolor(black)) xline(2001, lpattern(shortdash) lcolor(black)) xtitle("",si(medsmall)) xlabel(#10) ytitle("Gap in GDP prediction error", size(medsmall)) legend(off)
- save data\synth\synth_sanctions_40.dta, replace
- * Placebo test
- clear
- use "data\sanctions.dta"
- tsset countrycode year, year
- #delimit;
- set more off;
- local countrycode 1 2 3 4 6 7 8 9 10 11 13 15 16 17 18 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40;
- foreach i of local countrycode {;
- synth gdp
- fdi(1997) gdp(1990) gdp(1999) inflation(1997) educ2(1998) trade2(1999)
- ,
- trunit(`i') trperiod(2001)
- mspeperiod(1990(1)2001) resultsperiod(1990(1)2009)
- keep(data\synth\synth_sanctions_`i'.dta) replace;
- matrix country`i' = e(RMSPE); /* check the V matrix*/
- };
- foreach i of local countrycode {;
- matrix rownames country`i'=`i';
- matlist country`i', names(rows);
- };
- #delimit cr
- local countrycode 1 2 3 4 6 7 8 9 10 11 13 15 16 17 18 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
- foreach i of local countrycode {
- use data\synth\synth_sanctions_`i' ,clear
- keep _Y_treated _Y_synthetic _time
- drop if _time==.
- rename _time year
- rename _Y_treated treat`i'
- rename _Y_synthetic counterfact`i'
- gen gap`i'=treat`i'-counterfact`i'
- sort year
- save data\synth\synth_gap_sanctions`i'.dta, replace
- }
- use data\synth\synth_gap_sanctions40.dta, clear
- sort year
- save data\synth\placebo_sanctions40.dta, replace
- foreach i of local countrycode {
- merge year using data\synth\synth_gap_sanctions`i'
- drop _merge
- sort year
- save data\synth\placebo_sanctions.dta, replace
- }
- * All the placeboes on the same picture
- use data\synth\placebo_sanctions.dta, replace
- * Picture of the full sample, including outlier RSMPE
- #delimit;
- twoway
- (line gap1 year ,lp(solid)lw(vthin))
- (line gap2 year ,lp(solid)lw(vthin))
- (line gap4 year ,lp(solid)lw(vthin))
- (line gap6 year ,lp(solid)lw(vthin))
- (line gap8 year ,lp(solid)lw(vthin))
- (line gap9 year ,lp(solid)lw(vthin))
- (line gap10 year ,lp(solid)lw(vthin))
- (line gap11 year ,lp(solid)lw(vthin))
- (line gap13 year ,lp(solid)lw(vthin))
- (line gap15 year ,lp(solid)lw(vthin))
- (line gap16 year ,lp(solid)lw(vthin))
- (line gap17 year ,lp(solid)lw(vthin))
- (line gap18 year ,lp(solid)lw(vthin))
- (line gap20 year ,lp(solid)lw(vthin))
- (line gap21 year ,lp(solid)lw(vthin))
- (line gap22 year ,lp(solid)lw(vthin))
- (line gap23 year ,lp(solid)lw(vthin))
- (line gap24 year ,lp(solid)lw(vthin))
- (line gap25 year ,lp(solid)lw(vthin))
- (line gap26 year ,lp(solid)lw(vthin))
- (line gap27 year ,lp(solid)lw(vthin))
- (line gap28 year ,lp(solid)lw(vthin))
- (line gap29 year ,lp(solid)lw(vthin))
- (line gap30 year ,lp(solid)lw(vthin))
- (line gap31 year ,lp(solid)lw(vthin))
- (line gap32 year ,lp(solid)lw(vthin))
- (line gap33 year ,lp(solid)lw(vthin))
- (line gap34 year ,lp(solid)lw(vthin))
- (line gap35 year ,lp(solid)lw(vthin))
- (line gap36 year ,lp(solid)lw(vthin))
- (line gap37 year ,lp(solid)lw(vthin))
- (line gap38 year ,lp(solid)lw(vthin))
- (line gap39 year ,lp(solid)lw(vthin))
- (line gap40 year ,lp(solid)lw(thick)lcolor(black)), /*treatment unit, Zimbabwe*/
- yline(0, lpattern(shortdash) lcolor(black)) xline(2001, lpattern(shortdash) lcolor(black))
- xtitle("",si(small)) xlabel(#10) ytitle("Gap in GDP per capita prediction error", size(small))
- legend(off);
- #delimit cr
Add Comment
Please, Sign In to add comment