--------------------------------------------------------------------------------------
name: <Solomon Negash>log: ~\myReplications\synthetic-control\synthdid.smcllog type: smclopened on: 16 Dec 2018, 18:24:07 // Replication of Synthetic Control method - the last graphs 4-7 //1.1. Load dataset, tsset and loop through all units and store the results of synth using the keep option.. sysuse smoking, clear
(Tobacco Sales in 39 US States)
. tsset state year
panel variable: state (strongly balanced)
time variable: year, 1970 to 2000
delta: 1 unit. forval i=1/39{. qui synth cigsale retprice cigsale(1988) cigsale(1980) cigsale(1975), ///> xperiod(1980(1)1988) trunit(`i') trperiod(1989) keep(synth_`i', replace). } //2. Quitely loop through all saved datasets and create the relevant variables (years and treatment effects). Drop missing observations.. qui forval i=1/39{. 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. } //3. Load the first dataset from step 2 and merge with the rest of datasets.. use synth_1, clear
(Tobacco Sales in 39 US States)
. forval i=2/39{. qui merge 1:1 year using synth_`i', nogenerate. label var tr_effect_`i' "tr_effect_`i'" . }// Rename tr_effect_i to tte_j by ranking based on MSPE scores. . qui rename tr_effect_17 tte_1
. (...)
//4. Plot //Figure 4 (38 control states). set scheme s1mono . local lp. forval i=1/38 {. local lp `lp' line tte_`i' years, lcolor(gs12) || }. twoway `lp' || line tte_3 years, lcolor(black) lwidth(medium) text(-40 1984 "Passage of Proposition 99 --->", size(*0.75)) ///> legend(off) yline(0, lcolor(black) lwidth(thick) lpattern(dash)) xline(1989, lwidth(medium) lpattern(dash)) ///> caption(Re: Figure 4. Per-cap cig sales gaps in California & placebo gaps in 38 control states.). graph export synth38.png, replace
(file synth38.png written in PNG format)
// <image src="synth38.png" width="358" height="300"//Figure 5 (34 control states). drop tte_35 tte_36 tte_37 tte_38 tte_39 . local lp. forval i=1/34 {. local lp `lp' line tte_`i' years, lcolor(gs12) || . }. twoway `lp' || line tte_3 years, lcolor(black) lwidth(medium) text(-40 1984 "Passage of Proposition 99 --->", size(*0.75)) ///> legend(off) yline(0, lcolor(black) lwidth(thick) lpattern(dash)) xline(1989, lwidth(medium) lpattern(dash)) ///> caption(Re: Figure 5. Per-cap cig sales gaps in California & placebo gaps in 34 control states). graph export synth34.png, replace
(file synth34.png written in PNG format)
// <image src="synth34.png" width="358" height="300">//Figure 6 (29 control states). drop tte_30 tte_31 tte_32 tte_33 tte_34. local lp. forval i=1/29 {. local lp `lp' line tte_`i' years, lcolor(gs12) || . }. twoway `lp' || line tte_3 years, lcolor(black) lwidth(medium) text(-40 1984 "Passage of Proposition 99 --->", size(*0.75)) ///> legend(off) yline(0, lcolor(black) lwidth(thick) lpattern(dash)) xline(1989, lwidth(medium) lpattern(dash)) ///> caption(Re: Figure 6. Per-cap cig sales gaps in California & placebo gaps in 29 control states). graph export synth30.png, replace
(file synth30.png written in PNG format)
// <image src="synth30.png" width="358" height="300">//Figure 7 (19 control states). drop tte_20 tte_21 tte_22 tte_25 tte_23 tte_24 tte_26 tte_27 tte_28. local lp. forval i=1/19 {. local lp `lp' line tte_`i' years, lcolor(gs12) || . }. twoway `lp' || line tte_3 years, lcolor(black) lwidth(medium) text(-40 1984 "Passage of Proposition 99 --->", size(*0.75)) ///> legend(off) yline(0, lcolor(black) lwidth(thick) lpattern(dash)) xline(1989, lwidth(medium) lpattern(dash)) ///> caption(Re: Figure 7. Per-cap cig sales gaps in California & placebo gaps in 19 control states). graph export synth19.png, replace
(file synth19.png written in PNG format)
// <image src="synth19.png" width="358" height="300">. log close name: <Solomon Negash>log: ~\myReplications\synthetic-control\synthdid.smcllog type: smclclosed on: 16 Dec 2018, 18:24:21
--------------------------------------------------------------------------------------