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

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

**** REPLICATION OF TABLE 10 ****

clear all
set mem 2g
set more off

/*	
	OUTLINE
	1. REGRESSIONS
	2. TABLE FOR PAPER
*/

**************************
***** 1. REGRESSIONS *****
**************************

// Import survey data

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

keep if dep_inc==1

// Clustering

egen cluster=group(birthyr alsace)

drop born_1908_1913
g born_1908_1913=1*(birthyr>=1908 & birthyr<=1913 & sexe==1)
g born_1908_1913_fem=1*(birthyr>=1908 & birthyr<=1913 & sexe==2)

// Trust

foreach i in ecole justi polic armee parti{
	
	ivreghdfe confiance_`i' alsace perc_i_full /// 
		c.born_1908_1913_fem#c.alsace c.born_1908_1913#c.alsace c.p_g1_1908_1913#c.alsace c.p_g2_1908_1913#c.alsace if birthyr>1907, ///
		cluster(cluster) a(i.birthyr#i.sexe i.religion i.wave_enc i.parents) // 

	estimates store G0confiance_`i'
	qui sum confiance_`i' if e(sample)
	scalar mean_y=r(mean)
	estadd scalar mean_y

}

// Fixed effects

estfe . G0confiance*, labels(nationalite_pop "Individual controls" annee "Survey year FE" birthyr#sexe "YoB $ \times $ gender FE")
return list

// Vote

foreach var in vote_ERW_ever vote_P2002R1_ERW_post{ 
	
	ivreghdfe `var' alsace perc_i_full /// 
		c.born_1908_1913_fem#c.alsace c.born_1908_1913#c.alsace c.p_g1_1908_1913#c.alsace c.p_g2_1908_1913#c.alsace if birthyr>1907, ///
		cluster(cluster) a(i.birthyr#i.sexe i.religion i.wave_enc i.parents) // 

	estimates store G0`var'
	qui sum `var' if e(sample)
	scalar mean_y=r(mean)
	estadd scalar mean_y
	
	tab wave annee if e(sample), miss
}

// Fixed effects

estfe . G0vote*, labels(nationalite_pop "Individual controls" i.annee_fep#i.wave_enc "Survey year FE" birthyr#sexe "YoB $ \times $ gender FE")
return list

******************************
***** 2. TABLE FOR PAPER *****
******************************

// Labels

la var alsace 				"Alsace"
la var born_1908_1913 		"[0.3em] Born 1908-1913" 
la var born_1908_1913_fem 	"[0.3em] B. 1908-13 (Woman)" 
la var p_g1_1908_1913 		"[0.3em] Born 1908-13 (Father)" 
la var p_g2_1908_1913 		"[0.3em] Born 1908-13 (G.-father)" 
la var perc_i_full		 	"[0.3em] Conscription proxy (\%)"

// Trust

estout G0confiance_ecole G0confiance_justi G0confiance_polic G0confiance_armee G0confiance_parti G0vote_ERW_ever G0vote_P2002R1_ERW_post ///
	using "$results\\$program.tex", replace style(tex) type label ///
	cells(b(star fmt(%9.3f)) se(par fmt(%9.3f)))  ///
	collabels(none) ///
	mlabels(, span none prefix(\multicolumn{@span}{c}{) suffix(})) ///
	msign(--) starlevels(* .1 ** .05 *** .01) ///
	keep(alsace perc_i_full c.p_g1_1908_1913#c.alsace c.p_g2_1908_1913#c.alsace) ///
	order(alsace perc_i_full c.p_g1_1908_1913#c.alsace c.p_g2_1908_1913#c.alsace) ///
	varlabels(c.p_g1_1908_1913#c.alsace "[0.3em] Born 1908-13 (Father) $ \times $ Alsace" c.p_g2_1908_1913#c.alsace "[0.3em] Born 1908-13 (G.-father) $ \times $ Alsace") ///
	title(Party proximity and trust in institutions: Oblique transmission) ///
	prehead("\begin{table}[t!]" ///
	"\begin{center}" ///
	"\begin{threeparttable}" ///
	"\begin{scriptsize}" ///
	"\caption{@title}\label{$program}" ///
	"\begin{tabular*}{\columnwidth}{@{\extracolsep{\stretch{1}}}l*{@M}{c}@{}}" ///
	"\hline" "\hline" ///
	"&\multicolumn{1}{c}{(1)} 		&\multicolumn{1}{c}{(2)}  		&\multicolumn{1}{c}{(3)} 	&\multicolumn{1}{c}{(4)} 	&\multicolumn{1}{c}{(5)}  	&\multicolumn{1}{c}{(6)}		&\multicolumn{1}{c}{(7)}\\" ///
	"\cmidrule(lr){2-8}" ///
	" 	&\multicolumn{5}{c}{Trust in institutions}  &\multicolumn{2}{c}{Radical right vote} \\" ///
	"\cmidrule(lr){2-6} \cmidrule(lr){7-8}" /// 
	"\multicolumn{1}{l}{\textit{Dep. Variable}} &\multicolumn{1}{c}{Schooling} &\multicolumn{1}{c}{Judicial} &\multicolumn{1}{c}{Police} &\multicolumn{1}{c}{Army} &\multicolumn{1}{c}{Political} &\multicolumn{1}{c}{Ever}  &\multicolumn{1}{c}{Voted in} 		\\" ///
	"	&\multicolumn{1}{c}{system} &\multicolumn{1}{c}{system} &\multicolumn{1}{c}{} &\multicolumn{1}{c}{} &\multicolumn{1}{c}{parties}	 &\multicolumn{1}{c}{voted for} &\multicolumn{1}{c}{2002 R1}\\" ///
	"\hline") ///Vote Share of 
	posthead("\\") ///
	prefoot("%\\" ///
	"%\hline") ///
	postfoot("")

estout G0confiance_ecole G0confiance_justi G0confiance_polic G0confiance_armee G0confiance_parti G0vote_ERW_ever G0vote_P2002R1_ERW_post ///
	using "$results\\$program.tex", append style(tex) type label ///
	cells(b(star fmt(%9.3f)) se(par fmt(%9.3f)))  ///
	stats(mean_y N N_clust, lab("Mean dep. variable" "Observations" "Clusters") fmt(3 %9.0fc %9.0fc)) ///
	collabels(none) ///
	mlabels(, span none prefix(\multicolumn{@span}{c}{) suffix(})) ///
	msign(--) starlevels(* .1 ** .05 *** .01) ///
	drop(*) /// 
	indicate( ///	
	"Individual controls = 0.parents" ///	
	"Survey wave FE = 0.wave_enc" ///	
	"Year-of-birth FE = 0.birthyr#0.sexe" ///
	, labels(Yes )) ///
	prehead("") ///
	posthead("\\" ///
	"%\hline") ///
	prefoot("\hline") ///
	postfoot("\hline" "\hline" ///
	"\end{tabular*}" /// 
	"\end{scriptsize}" ///
	"\begin{tablenotes}[normal,flushleft]" ///
	"\begin{scriptsize}" ///
	"\item \emph{Notes}:" /// 
	"Reduced-form estimates of the potential mechanism. " ///
	"Data comes from the 2002 and 2007 French Electoral Panel (\textit{Panel \'electoral fran\c{c}ais}). " ///
	"The unit of observation is an individual. " ///
	"Standard errors clustered at year-of-birth $ \times $ region level in parentheses. " ///
	"Columns (1) to (5): Results with measures of trust in institutions are the outcome; " ///
	"Columns (6) to (7): Results with past vote for the radical right as the outcome. " ///
	"Year-of-birth $ \times $ gender fixed effects are included in all specifications. " ///
	"* significant at 10\%; ** at 5\%; *** at 1\%. " ///	
	"\end{scriptsize}" ///
	"\end{tablenotes}" ///
	"\end{threeparttable} " ///
	"\end{center}" ///
	"\end{table}") //

cap log close


cap log close
