/**********************/
/*Clean and set memory*/
/**********************/
clear all
set matsize 5000
set more off

/******************/
/*Install programs*/
/******************/
cap ssc install xtabond2 
cap ssc install xtivreg2 
cap ssc install spmat 
cap ssc install spmack

/*********************/
/*Sets base directory*/
/*********************/
global project "/bbkinghome/pascual/winprofile/mydocs/replication_files_ddcg/"  /* Set base directory                         */

/* Figure 3: local projections RA (requires impulse_ra_alt.dta, which is generated by Table4_final.do) */
use "$project/results/impulse_ra_alt", clear
split parm, p("c")
keep if parm2!=""
destring parm2, force replace
gen time=parm2-16
tsset time

/* Plots figure */
twoway (tsline estimate, lcolor(black) lpattern(solid)) ///
       (tsline min95, lcolor(gray) lpattern(dash)) ///
       (tsline max95, lcolor(gray) lpattern(dash)) ///
       , ytitle("Change in GDP per capita log points") xtitle(Years around democratization) legend(off) ///
	   graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) plotregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) ///
	   xlabel(-15(5)30) ylabel(-20(10)45)
graph export "$project/results/ImpVarRA.eps", as(eps) preview(off) replace 

/*Figure 4: local projections IPW (requires impulse_ipw_alt.dta, which is generated by Table4_final.do) */
use "$project/results/impulse_ipw_alt", clear
split parm, p("c")
keep if parm2!=""
destring parm2, force replace
gen time=parm2-16
tsset time

/* Plots figure */
twoway (tsline estimate, lcolor(black) lpattern(solid)) ///
       (tsline min95, lcolor(gray) lpattern(dash)) ///
       (tsline max95, lcolor(gray) lpattern(dash)) ///
       , ytitle("Change in GDP per capita log points") xtitle(Years around democratization) legend(off) ///
	   graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) plotregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) ///
	   xlabel(-15(5)30) ylabel(-20(10)45)
graph export "$project/results/ImpVarIPW.eps", as(eps) preview(off) replace 


/*Figure 5: local projections IPWRA (requires impulse_ipwra_alt.dta, which is generated by Table4_final.do) */
use "$project/results/impulse_ipwra_alt", clear
split parm, p("c")
keep if parm2!=""
destring parm2, force replace
gen time=parm2-16
tsset time

/* Plots figure */
twoway (tsline estimate, lcolor(black) lpattern(solid)) ///
       (tsline min95, lcolor(gray) lpattern(dash)) ///
       (tsline max95, lcolor(gray) lpattern(dash)) ///
       , ytitle("Change in GDP per capita log points") xtitle(Years around democratization) legend(off) ///
	   graphregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) plotregion(fcolor(white) lcolor(white) ifcolor(white) ilcolor(white)) ///
	   xlabel(-15(5)30) ylabel(-20(10)45)
graph export "$project/results/ImpVarIPWRA.eps", as(eps) preview(off) replace 

