@liuyuxi
2021-07-19T09:23:26.000000Z
字数 3536
阅读 33
stata
*合成控制基本结果图
use synth_data,clear
format _time %tm
gen effect = _Y_treated- _Y_synthetic
twoway (line _Y_treated _time, lcolor(black)) ///
(line _Y_synthetic _time, lcolor(black)) ///
(pcarrowi 103 686.5 103 689.5, lp(dash) lc(black*0.5) mcolor(black*0.5)) ///
,xline(690,lp(dash) lcolor(black*0.8) ) ///
legend(size(*1)) ///
ytitle("AQI") xtitle(" ") ///
legend(col(1) pos(2 ) ) ///
xlabel(684(3)703) ylabel(30(20)180) ///
text(110 688 "Policy Month" ) ///
legend(label(1 "Treated Group") label(2 "Untreated Group") label(3 " Policy Month")) ///
legend(col(3) pos(6 ) )
*合成控制净效应
use synth_data,clear
format _time %tm
gen effect = _Y_treated- _Y_synthetic
twoway (line effect _time, lcolor(black)) ///
(pcarrowi -28 686.5 -28 689.5, lp(dash) lc(black*0.5) mcolor(black*0.5)) ///
,xline(690,lp(dash) lcolor(black*0.5) ) ///
yline(0,lp(dash) lcolor(black*0.5) ) ///
legend(size(*1)) ///
ytitle("AQI") xtitle(" ") ///
legend(col(1) pos(2 ) ) ///
xlabel(684(3)703) ylabel(-50(10)10) ///
text(-25 688 "Policy Month" ) ///
legend(label(1 "Treated Effect") label(2 "Policy Month") ) ///
legend(col(3) pos(6 ))
qlean
,qleanmono
等模板模板
. sysuse "auto.dta", clear . twoway scatter price weight
. twoway scatter price weight, scheme(qlean)
. twoway scatter price weight, scheme(qleanmono)
. twoway scatter price weight if foreign==0 || scatter price weight if foreign==1
. twoway scatter price weight if foreign==0 || scatter price weight if foreign==1, scheme(qlean)
. twoway scatter price weight if foreign==0 || scatter price weight if foreign==1, scheme(qleanmono)
. sysuse uslifeexp,clear. twoway line le_male year || line le_female year. twoway line le_male year || line le_female year, scheme(qlean)
. twoway line le_male year || line le_female year, scheme(qleanmono)
. sysuse lifeexp, clear. gen lgnppc = ln(gnppc)
. gr matrix popgr lexp lgnp safe
. gr matrix popgr lexp lgnp safe, scheme(qlean)
. gr matrix popgr lexp lgnp safe, scheme(qleanmono)
. sysuse nlsw88, clear. graph hbar (mean) wage, over(smsa) over(married) over(collgrad)
. graph hbar (mean) wage, over(smsa) over(married) over(collgrad) scheme(qlean)
. ssc install scheme_tufte, replace . ssc install scheme-burd, replace . net install gr0002_3.pkg
. sysuse auto, clear. twoway lfitci mpg weight || scatter mpg weight. twoway lfitci mpg weight || scatter mpg weight, scheme(qlean) mc(ply3)
. twoway lfitci mpg weight || scatter mpg weight, scheme(tufte)
. twoway lfitci mpg weight || scatter mpg weight, scheme(burd)
. twoway lfitci mpg weight || scatter mpg weight, scheme(lean1)
. twoway lfitci mpg weight || scatter mpg weight, scheme(lean2)
plotplain
或plottig
模板
*散点图
graph twoway (scatter nkill nevents if region==12 & nevents<=500 & nkill<=1000) ///
(scatter nkill nevents if region==7 & nevents<=500 & nkill<=1000) ///
(scatter nkill nevents if region==6 & nevents<=500 & nkill<=1000) ///
, scheme(plottig) legend(label(1 Western Europe) label(2 North America) label(3 MENA)) name(s2m1) title("plottig")
graph twoway (scatter nkill nevents if region==12 & nevents<=500 & nkill<=1000) ///
(scatter nkill nevents if region==7 & nevents<=500 & nkill<=1000) ///
(scatter nkill nevents if region==6 & nevents<=500 & nkill<=1000) ///
, scheme(plottigblind) legend(label(1 Western Europe) label(2 North America) label(3 MENA)) name(s2c1) title("plottigblind")
*折线图
graph twoway (line nevents iyear if region==12) (line nevents iyear if region==7) (line nevents iyear if region==6), ///
scheme(plottig) legend(order(1 "Western Europe" 2 "North America" 3 "MENA")) name(s2m2, replace) title("plottig") xline(2003) ///
text(8 2003 "Iraq war", place(e))
graph twoway (line nevents iyear if region==12) (line nevents iyear if region==7) (line nevents iyear if region==6), ///
scheme(plottigblind) legend(order(1 "Western Europe" 2 "North America" 3 "MENA")) name(s2c2) title("plottigblind") xline(2003) ///
text(8 2003 "Iraq war", place(e))
*图形组合
graph combine s2m1 s2c1 s2m2 s2c2, iscale(0.5)
graph export plotplain5.eps, replace
graph drop s2m1 s2c1 s2m2 s2c2