**********************************************************************************
*
* Figure A5: Historical newspapers: Newspaper coverage in the vicinity of speeches
*
**********************************************************************************
 
global program "FigureA5"

cap log close
cap log using "$log_files/log_$program$today", replace

clear all
set mem 2g
set more off
set matsize 11000
set scheme s1color

***************************
***** 1. PREPARE DATA *****
***************************

// Get data

use "$data/Data_Chronicling_Panel.dta", replace 

xtset county week

****************************
***** 2. EXPORT FIGURE *****
****************************

* manually generate lags and leads
gen week_speech = week if speech ==1
bysort county: egen min_week_speech=min(week_speech)

gen l1_speech = l.speech
gen l2_speech = l2.speech
gen l3_speech = l3.speech
gen l4_speech = l4.speech
replace l4_speech = 1 if week > min_week_speech +3 & min_week_speech!=.

gen f1_speech = f.speech
gen f2_speech = f2.speech
gen f3_speech = f3.speech
gen f4_speech = f4.speech
replace f4_speech = 1 if week < min_week_speech - 3 & min_week_speech!=.

eststo delta: reghdfe delta_Bryan_McKinley  f4_speech f3_speech f2_speech  speech  l1_speech-l4_speech, absorb(county week) cluster(county)

coefplot delta, vertical ///
keep( f4_speech f3_speech f2_speech x  speech  l*) order(f4_speech f3_speech f2_speech x  speech  l*)   ///
ciopts(recast(rcap))  levels(95) ///
yline(0, lpattern(dash)) ylabel(-1(1)2, angle(0) format(%9.0f)) yline(1, lpattern(dash) lcolor(gs15)) yline(2, lpattern(dash) lcolor(gs15)) yline(-1, lpattern(dash) lcolor(gs15)) /// 
msymbol(S) msize(small) mfcolor(white) pstyle(p3) fcolor(white) ///
mlabel mlabsize(small) format(%9.3f) mlabposition(3) mlabcolor(navy) mlabgap(*2) ///
ytitle("Coefficient (95% C.I.)") /// 
legend(off) title("# Newspaper Mentions of Bryan - McKinley", size(medium)) ///
coeflabels( f4_speech = "< -4"  f3_speech = "-3"  f2_speech = "-2" speech = "Speech" l1_speech = "1"  l2_speech = "2"  l3_speech = "3"  l4_speech = "> 4") ///
name("delta", replace)

eststo delta_Bryan: reghdfe nwsp_Bryan  f4_speech f3_speech f2_speech  speech  l1_speech-l4_speech, absorb(county week) cluster(county)

coefplot delta_Bryan, vertical ///
keep( f4_speech f3_speech f2_speech   speech  l*)   ///
ciopts(recast(rcap))  levels(95) ///
yline(0, lpattern(dash)) ylabel(-1(1)2, angle(0) format(%9.0f)) yline(1, lpattern(dash) lcolor(gs15)) yline(2, lpattern(dash) lcolor(gs15))  yline(-1, lpattern(dash) lcolor(gs15)) /// 
msymbol(S) msize(small) mfcolor(white) pstyle(p3) fcolor(white) ///
mlabel mlabsize(small) format(%9.3f) mlabposition(3) mlabcolor(navy) mlabgap(*2) ///
ytitle("Coefficient (95% C.I.)")  /// 
legend(off) title("# Newspaper Mentions of Bryan", size(medium)) ///
coeflabels( f4_speech = "< -4"  f3_speech = "-3"  f2_speech = "-2" speech = "Speech" l1_speech = "1"  l2_speech = "2"  l3_speech = "3"  l4_speech = "> 4") ///
name("delta_Bryan", replace)

eststo delta_McKinley: reghdfe nwsp_McKinley  f4_speech f3_speech f2_speech   speech  l1_speech-l4_speech, absorb(county week) cluster(county)

coefplot delta_McKinley, vertical ///
keep(f4_speech f3_speech f2_speech  speech  l*)   ///
ciopts(recast(rcap))  levels(95) ///
yline(0, lpattern(dash)) ylabel(-1(1)2, angle(0) format(%9.0f)) yline(1, lpattern(dash) lcolor(gs15)) yline(2, lpattern(dash) lcolor(gs15)) yline(-1, lpattern(dash) lcolor(gs15)) /// 
msymbol(S) msize(small) mfcolor(white) pstyle(p3) fcolor(white) ///
mlabel mlabsize(small) format(%9.3f) mlabposition(3) mlabcolor(navy) mlabgap(*2) ///
ytitle("Coefficient (95% C.I.)")  /// 
legend(off) title("# Newspaper Mentions of McKinley", size(medium))  ///
coeflabels( f4_speech = "< -4"  f3_speech = "-3"  f2_speech = "-2" speech = "Speech" l1_speech = "1"  l2_speech = "2"  l3_speech = "3"  l4_speech = "> 4") ///
name("delta_McKinley", replace)

graph combine delta delta_Bryan delta_McKinley,  col(1) ysize(8) xsize(4)
graph export "$figures/$program.pdf", as(pdf) replace

cap log close
 
