global program "EEREV-D-21-00004_FigureB4"

cap log close
cap log using "$log\log_$program$today", replace

**** REPLICATION OF FIGURE B4 ****

clear all
set mem 2g
set more off

/*	
	OUTLINE
	1. DESCRIPTIVE GRAPHS
*/

*********************************
***** 1. DESCRIPTIVE GRAPHS *****
*********************************

// Import candidate data

use $data\EEREV-D-21-00004_Data_Parties.dta, clear

// Anti-elite CHES and Negative mentions

preserve

drop if ael==.
reg ael neg, cluster(party)
matrix b=e(b)
scalar b1_neg=b[1,1]
scalar cons_neg=b[1,2]

twoway ///
	(scatter ael neg, mlabel(party_annee) mlabsize(vsmall) mlabcolor(navy)) /// 
	(lfit ael neg, lp(dash) lcolor(maroon) range(-.8 8.8)), ///
	ytitle("Antielite salience index (CHES)", margin(vsmall)) ylabel(0(5)10, angle(0) format(%5.0f)) xlabel(0(4)8, format(%5.0f)) yscale(r(-1 11)) xscale(r(-.8 8.8)) /// 
	xtitle("Share of negative quasi-sentences (CMP)", margin(small)) ///
	legend(off) graphregion(color(white)) name(ael, replace)

restore

// LR CHES and Negative mentions

preserve

drop if lrg==.

g lrg2=lrg*lrg
reg neg lrg lrg2, cluster(party)
matrix b=e(b)
scalar b1_neg=b[1,1]
scalar b2_neg=b[1,2]
scalar cons_neg=b[1,3]

twoway ///
	(scatter neg lrg, mlabel(party_annee) mlabsize(vsmall) mlabcolor(navy)) /// 	
	(function y=cons_neg+b1_neg*x+b2_neg*x^2, lp(dash) lcolor(maroon) range(-1 11)), ///
	ytitle("Share of negative quasi-sentences (CMP)", margin(vsmall)) ylabel(0(10)20, angle(0) format(%5.0f)) xlabel(0(5)10, format(%5.0f)) yscale(r(-2 22)) xscale(r(-1 11)) /// 
	xtitle("Left-Right Index (CHES)", margin(small)) ///
	legend(off) graphregion(color(white)) name(lrgen, replace)

restore

// Combine graphs

graph combine ael lrgen ///
	, c(2) graphregion(color(white)) imargin(vsmall)
graph export "$results\\$program.png", replace width(7200) height(3000)

cap log close
