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

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

**** REPLICATION OF FIGURE 3 ****

clear all
set mem 2g
set more off

/*	
	OUTLINE
	1. DRAW GRAPH
*/

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

// Parameters

scalar tau_R1 = 0.1
scalar tau_R2 = 0.5
scalar tau_M = 0
scalar tau_M1 = 0
scalar tau_M2 = 0
scalar tau_H = 0.5
scalar tau_L = 0
scalar c_H = 0.2
scalar c_L = 0

// Make graphs: Little polarization

twoway	(function y = 0.5 - 0.5*(tau_R1+tau_M1) + (tau_H-tau_L)*x + 0.5*(c_L-c_H)*x/(tau_R1-tau_M1) + tau_L - 0.5*c_L/(tau_R1-tau_M1), range(0 .4) lcolor(navy) lwidth(medthick)) ///
		(function y = 0.5 + 0.5*(tau_R1+tau_M1) + (tau_L-tau_H)*x + 0.5*(c_L-c_H)*x/(tau_R1-tau_M1) - tau_L - 0.5*c_L/(tau_R1-tau_M1), range(0 .37) lcolor(navy*.5) lpattern(dash) lwidth(medthick)) ///
		(function y = (c_H-c_L)*x/(tau_R1-tau_M1) + c_L/(tau_R1-tau_M1), range(0 .4) lcolor(gs8) lpattern("....._") lwidth(medthick)), ///
		xlabel(0(.1).4, angle(0) format(%9.1f) nogrid) xtitle("Share conscripted") ///
		ylabel(0(.2).8, angle(0) format(%9.1f)) ytitle("Share of registered voters") ///
		graphregion(color(white)) title("Low polarization", ring(0)) name(low, replace) ///
		leg(lab(1 "Radical") lab(2 "Moderate") lab(3 "Abstention") c(3) region(color(white)) pos(1) ring(0) symxsize(*0.5) size(vsmall))

// Make graphs: Lots of polarization

twoway	(function y = 0.5 - 0.5*(tau_R2+tau_M2) + (tau_H-tau_L)*x + 0.5*(c_L-c_H)*x/(tau_R2-tau_M2) + tau_L - 0.5*c_L/(tau_R2-tau_M2), range(0 .4) lcolor(navy) lwidth(medthick)) ///
		(function y = 0.5 + 0.5*(tau_R2+tau_M2) + (tau_L-tau_H)*x + 0.5*(c_L-c_H)*x/(tau_R2-tau_M2) - tau_L - 0.5*c_L/(tau_R2-tau_M2), range(0 .4) lcolor(navy*.5) lpattern(dash) lwidth(medthick)) ///
		(function y = (c_H-c_L)*x/(tau_R2-tau_M2) + c_L/(tau_R2-tau_M2), range(0 .4) lcolor(gs8) lpattern("....._") lwidth(medthick)), ///
		xlabel(0(.1).4, angle(0) format(%9.1f) nogrid) xtitle("Share conscripted") ///
		ylabel(0(.2).8, angle(0) format(%9.1f)) ytitle("Share of registered voters") ///
		graphregion(color(white)) title("High polarization", ring(0)) name(high, replace) ///
		leg(lab(1 "Radical") lab(2 "Moderate") lab(3 "Abstention") c(3) region(color(white)) pos(1) ring(0) symxsize(*0.5) size(vsmall))

// Marginal effect

scalar alpha1 = 1

twoway	(function y = (tau_H-tau_L)*alpha1 + 0.5*(c_L-c_H)*alpha1/(x-tau_M), range(0.1 0.5) lcolor(navy) lwidth(medthick)) ///
		(function y = (tau_L-tau_H)*alpha1 + 0.5*(c_L-c_H)*alpha1/(x-tau_M), range(0.1 0.5) lpattern(dash) lcolor(navy*.5) lwidth(medthick)) ///
		(function y = (c_H-c_L)*alpha1/(x-tau_M) + c_L/(x-tau_M), range(0.1 0.5) lcolor(gs8) lpattern("....._") lwidth(medthick)), ///
		yline(0, lpattern("-.-")) ///
		xlabel(.1(.1).5, angle(0) format(%9.1f) nogrid) xtitle("Polarization") ///				
		ylabel(-2(1)2, angle(0) format(%9.0f)) ytitle("Marginal effect of conscription") ///
		graphregion(color(white)) title("Marginal effects", ring(0)) name(mfx, replace) ///
		leg(lab(1 "Radical") lab(2 "Moderate") lab(3 "Abstention") c(3) region(color(white)) pos(1) ring(0) symxsize(*0.5) size(small))
	
// Combine graphs

grc1leg high low mfx, c(3) graphregion(color(white)) imargin(vsmall) legendfrom(mfx) /// 
 	b1title("", size(vsmall)) l1title("", size(vsmall)) 
graph export "$results\\$program.png", replace width(5400) height(1800)

cap log close
