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

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

**** REPLICATION OF FIGURE C1 ****

clear all
set mem 2g
set more off

/*	
	OUTLINE
	1. GRAPH
*/

********************
***** 1. GRAPH *****
********************

// Import data

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

// Generate periods

gen post=1*(annee>=1988)

// Collapse by period

collapse (mean) perc_voixexd_ins perc_bna_ins, by(com alsace post perc_i_full)

// Reshape

reshape wide perc_voixexd_ins perc_bna_ins, i(com alsace) j(post)

// Collapse by percentile

foreach case in perc_i_full{
	xtile I_`case'=`case', n(50)
	replace I_`case'=2*I_`case'
}

collapse (mean) perc_voixexd_ins* perc_bna_ins*, by(I_perc_i_full)

// Vote

cap g perc_voixexd_ins0_g=perc_voixexd_ins0+15 // To rescale y-axis

twoway ///
	(scatter perc_voixexd_ins0_g I_perc_i_full, mcolor(navy*.3) msymbol(D)) /// 	
	(lfit perc_voixexd_ins0_g I_perc_i_full, lp(dash) lcolor(gs14)) ///
	(scatter perc_voixexd_ins1 I_perc_i_full, mcolor(navy)) /// 	
	(lfit perc_voixexd_ins1 I_perc_i_full, lp(dash) lcolor(maroon)), ///
	title("Radical right-wing 1995-2017", ring(0)) ///
	ytitle("Percent of registered voters", margin(vsmall)) ///		
	ylabel(15 "0" 16 "1" 17 20(4)24, angle(0) format(%5.0f)) yscale(r(15 25)) ///
	xtitle("Conscription percentile", margin(medium)) ///
	legend(off) graphregion(color(white)) name(vote, replace) //

// Abstention

twoway ///
	(scatter perc_bna_ins1 I_perc_i_full, mcolor(navy*.3) msymbol(D)) /// 	
	(scatter perc_bna_ins0 I_perc_i_full, mcolor(navy)) /// 	
	(lfit perc_bna_ins1 I_perc_i_full, lp(dash) lcolor(gs14)) ///
	(lfit perc_bna_ins0 I_perc_i_full, lp(dash) lcolor(maroon)), ///
	title("Abstention 1965-1974", ring(0)) ///
	ytitle("Percent of registered voters", margin(vsmall)) ///	
	ylabel(13(4)21, angle(0) format(%5.0f)) yscale(r(12 22)) ///
	xtitle("Conscription percentile", margin(medium)) ///
	legend(off) graphregion(color(white)) name(abst, replace) //

// Combine graphs

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

cap log close
