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

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

**** REPLICATION OF TABLE C17 ****

clear all
set mem 2g
set more off

/*	
	OUTLINE
	1. PREPARE DATA
	2. REGRESSIONS
	3. TABLE FOR PAPER
*/

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

// Import data

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

keep if dep_inc==1

tab annee, sum(alsace)
drop if annee==2004 // Only alsace

// Each party separately
	
levelsof proximite, local(levels)
tab proximite, g(prox_)

// Transmission variables

cap drop born_1908_1913 born_1914_1927
g born_1908_1913=1*(birthyr>=1908 & birthyr<=1913 & sexe==1)
g born_1908_1913_fem=1*(birthyr>=1908 & birthyr<=1913 & sexe==2)
g born_1914_1927=1*(birthyr>=1914 & birthyr<=1927 & sexe==1)
g born_1914_1927_fem=1*(birthyr>=1914 & birthyr<=1927 & sexe==2)

// Code parties not present as missing

forvalues i=1(1)21{ 

levelsof annee, local(levels)
foreach l of local levels{
	
	qui sum prox_`i' if annee==`l'
	g tmp=r(sd)
	replace prox_`i'=. if tmp==0 & annee==`l'
	drop tmp
	
}
}

// Rad right parties

g prox_32=max(prox_4, prox_13, prox_19) // Droite de Millon, MPF, RPF
g prox_33=max(prox_12, prox_32) // MNR, Droite de Millon, MPF, RPF

**************************
***** 2. REGRESSIONS *****
**************************

// Regressions

foreach var in confiance11 proximiteFN prox_9 prox_12 prox_32 prox_33{
	
	reghdfe `var' alsace /// 
		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(i.birthyr#i.alsace) a(i.birthyr#i.sexe i.nationalite_pop i.religion i.anciennete i.annee)

	estimates store G0`var'
	qui sum `var' if e(sample)
	scalar mean_y=r(mean)
	estadd scalar mean_y

}

// Just coefficients with variation

foreach var in prox_12 prox_32 prox_33{
	
	reghdfe `var' alsace /// 
		c.p_g1_1908_1913#c.alsace c.p_g2_1908_1913#c.alsace if birthyr>1907, ///
		cluster(i.birthyr#i.alsace) a(i.birthyr#i.sexe i.nationalite_pop i.religion i.anciennete i.annee)

	estimates store G0`var'
	qui sum `var' if e(sample)
	scalar mean_y=r(mean)
	estadd scalar mean_y

}


******************************
***** 3. TABLE FOR PAPER *****
******************************

// Fixed effects

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

// Labels

la var born_1908_1913 "Born 1908-1913" 
la var alsace "Alsace"

// Trust

estout G0confiance11 G0proximiteFN G0prox_9 G0prox_12 G0prox_32 G0prox_33 ///
	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 c.born_1908_1913#c.alsace c.born_1908_1913_fem#c.alsace c.p_g1_1908_1913#c.alsace c.p_g2_1908_1913#c.alsace) ///
	order(alsace c.born_1908_1913#c.alsace c.born_1908_1913_fem#c.alsace c.p_g1_1908_1913#c.alsace c.p_g2_1908_1913#c.alsace) ///
	varlabels(c.born_1908_1913_fem#c.alsace "[0.3em] Born 1908-1913 (Woman) $ \times $ Alsace" c.p_g1_1908_1913#c.alsace "[0.3em] Born 1908-1913 (Father) $ \times $ Alsace" c.p_g2_1908_1913#c.alsace "[0.3em] Born 1908-1913 (Grand-father) $ \times $ Alsace") ///
	title(Party proximity and trust in institutions: Intergenerational transmission) ///
	prehead("\begin{table}[h!]" ///
	"\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)} \\" ///	
	"\cmidrule(lr){2-7}" ///
	"& Trust & \multicolumn{5}{c}{\textit{Which party do you feel closer to, or less distant from}}\\" ///
	"\cmidrule(lr){2-2} \cmidrule(lr){3-7}" ///
	"\multicolumn{1}{l}{\textit{Dep. Variable}} &\multicolumn{1}{c}{Elected}&\multicolumn{1}{c}{\textit{Radical right}}	&\multicolumn{1}{c}{\textit{National}} &\multicolumn{1}{c}{\textit{National Rep}}&\multicolumn{1}{c}{\textit{Rally/Movement}}	&\multicolumn{1}{c}{\textit{Other}}	\\" ///  
	"&\multicolumn{1}{c}{politicians}&\multicolumn{1}{c}{\textit{(any)}}&\multicolumn{1}{c}{\textit{Front}}	&\multicolumn{1}{c}{\textit{Movement}}	&\multicolumn{1}{c}{\textit{for France}}	&\multicolumn{1}{c}{\textit{radical right}}	\\" ///  
	"\hline") ///Vote Share of 
	posthead("\\") ///
	prefoot("\\") ///
	postfoot("")

estout G0confiance11 G0proximiteFN G0prox_9 G0prox_12 G0prox_32 G0prox_33 ///
	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 r2, lab("Mean dep. variable" "Observations" "Clusters" "$ R $-squared") fmt(3 %9.0fc %9.0fc 2)) ///
	collabels(none) ///
	mlabels(, span none prefix(\multicolumn{@span}{c}{) suffix(})) ///
	msign(--) starlevels(* .1 ** .05 *** .01) ///
	drop(*) /// 
	indicate( ///
	"Individual controls = 0.nationalite_pop" ///	
	"Survey year FE = 0.annee" ///
	"Year-of-birth FE = 0.birthyr#0.sexe" ///
	, labels(Yes )) ///
	prehead("") ///
	posthead("") ///
	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. " ///
	"The unit of observation is an individual. " ///
	"Standard errors clustered at year-of-birth $ \times $ region level in parentheses. " ///
	"Each column presents a different estimation result. " ///
	"Column (1): Intergenerational transmission of attitudes; " ///
	"Column (2): proximity to radical right-wing parties; " ///
	"Column (3): proximity to the National Front; " ///
	"Column (4): proximity to the National Republican Movement; " ///
	"Column (5): proximity to the Rally for France and the Movement for France; " ///
	"Column (6): proximity to the National Republican Movement, the Rally for France, and the Movement for France. " ///
	"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
