{smcl}
{com}{sf}{ul off}{txt}
{com}. 
. **** REPLICATION OF FIGURE B5 ****
. 
. clear all
{res}{txt}
{com}. set mem 2g
{txt}{bf:set memory} ignored.
{p 4 4 2}
Memory no longer
needs to be set in modern Statas;
memory adjustments are performed on the fly
automatically.
{p_end}

{com}. set more off
{txt}
{com}. 
. /*      
>         OUTLINE
>         1. DESCRIPTIVE GRAPHS
> */
. 
. *********************************
. ***** 1. DESCRIPTIVE GRAPHS *****
. *********************************
. 
. // Import candidate data
. 
. use $data\EEREV-D-21-00004_Data_Candidates.dta, clear
{txt}
{com}. 
. // Change years to have more space
. 
. tostring annee, g(annee_str)
{txt}annee_str generated as {res:str4}

{com}. recode annee (1969=1971) (1974=1977) (1995=1991) (2002=1999) (2007=2005) (2012=2011), g(annee_tmp)
{txt}(66 differences between {bf:annee} and {bf:annee_tmp})

{com}. labmask annee_tmp, values(annee_str)
{txt}
{com}. 
. sort annee
{txt}
{com}. 
. // Left-hand-side graph
. 
. twoway (scatter neg_D annee_tmp, mcolor(navy) msize(small)) ///
>         (scatter neg_D annee_tmp [w=poll], msymbol(Oh) mcolor(maroon) mlwidth(thin)) /// mlstyle(dotmark) ///
>         , yline(0, lpattern(..-) lcolor(gs8)) graphregion(color(white)) ///
>         legend(label(1 "Position") label(2 "Polls") order(1 2) cols(1) symx(*0.5) region(col(white)) pos(10) ring(0)) ///   
>         ytitle("Difference from election weighted average", margin(vsmall)) ///
>         xtitle("Election year", margin(medium)) name(posneg, replace) ///
>         ylabel(-.2 0 .2 .4, angle(0) format(%5.1f)) yscale(r(-.26 .46)) ///
>         xlabel(1965 1971 "1969" 1977 "1974" 1991 "1995" 1999 "2002" 2005 "2007" 2011 "2012" 2017) xscale(r(1960 2022)) //
{txt}(analytic weights assumed)
(analytic weights assumed)
(analytic weights assumed)
{res}{txt}
{com}. 
. // Right-hand-side graph
. 
. twoway (scatter neg_P annee_tmp, c(l) lpattern(dash) lcolor(maroon) mcolor(navy)) /// msymbol(S)
>         , yline(0, lpattern(..-) lcolor(gs8)) graphregion(color(white)) ///
>         legend(label(1 "Polarization") order(1) cols(1) symx(*0.5) region(col(white))) ///  pos(2) ring(0) 
>         ytitle("Dalton (2008)'s polarization index", margin(vsmall)) ///
>         xtitle("Election year", margin(medium)) name(dalton, replace) ///
>         ylabel(0 .05 .1 .15, angle(0) format(%5.2f)) yscale(r(-.015 .165)) ///
>         xlabel(1965 1971 "1969" 1977 "1974" 1991 "1995" 1999 "2002" 2005 "2007" 2011 "2012" 2017) xscale(r(1960 2022)) //
{res}{txt}
{com}. 
. // Combine graphs
. 
. graph combine posneg dalton ///
>         , c(2) graphregion(color(white)) imargin(vsmall) //ycommon
{res}{txt}
{com}. graph export "$results\\$program.png", replace width(7200) height(3000)
{txt}{p 0 4 2}
file {bf}
D:\Dropbox\SVLACHOS\Research\Malgre_nous\Replication_files\Results\EEREV-D-21-00004_FigureB5.png{rm}
saved as
PNG
format
{p_end}

{com}. 
. cap log close
{smcl}
{com}{sf}{ul off}