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

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

**** REPLICATION OF TABLE 1 ****

clear all
set mem 2g
set more off

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

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

// Improt Microcensus data

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

keep if male==1

// Controls vector

global controls "frenchnat germannat protestant other speakfrench hhold_head hhold_size"

// Full sample (eligibility)

reghdfe index eligible, cluster(birthyr) noabsorb
estimates store OLS
qui sum index if e(sample)
scalar mean_y=r(mean)
estadd scalar mean_y

// Within municipality

reghdfe index eligible age age2 $controls, cluster(birthyr) a(com_hist)
estimates store OLS_FE
qui sum index if e(sample)
scalar mean_y=r(mean)
estadd scalar mean_y
test age=age2=frenchnat=germannat=other=protestant=speakfrench=hhold_head=hhold_size=0
scalar F_stat=r(p)
estadd scalar F_stat
		
// Within yob

reghdfe index $controls, cluster(birthyr) a(com_hist birthyr) // keepsing // male eligible age age2 
estimates store com_ctr
qui sum index if e(sample)
scalar mean_y=r(mean)
estadd scalar mean_y
test frenchnat=germannat=other=protestant=speakfrench=hhold_head=hhold_size=0 // age=age2=
scalar F_stat=r(p)
estadd scalar F_stat

// Only eligible

reghdfe index age age2 $controls if eligible==1, cluster(birthyr) a(com_hist) // keepsing
estimates store eligible_ctr
sum index if e(sample)
scalar mean_y=r(mean)
estadd scalar mean_y
margins, dydx(age) atmeans //  
test age=age2=frenchnat=germannat=other=protestant=speakfrench=hhold_head=hhold_size=0
scalar F_stat=r(p)
estadd scalar F_stat

// Within birthyr eligible

reghdfe index $controls if eligible==1, cluster(birthyr) a(com_hist birthyr) // keepsing
estimates store yob_ctr
qui sum index if e(sample)
scalar mean_y=r(mean)
estadd scalar mean_y
test frenchnat=germannat=other=protestant=speakfrench=hhold_head=hhold_size=0
scalar F_stat=r(p)
estadd scalar F_stat

// Only always-takers

reghdfe index age age2 $controls if eligible==0 & male==1, cluster(birthyr) a(com_hist) // keepsing
estimates store always_ctr
sum index if e(sample)
scalar mean_y=r(mean)
estadd scalar mean_y
margins, dydx(age) atmeans //  
test age=age2=frenchnat=germannat=other=protestant=speakfrench=hhold_head=hhold_size=0
scalar F_stat=r(p)
estadd scalar F_stat

// Within birthyr eligible always-takers

reghdfe index $controls if eligible==0, cluster(birthyr) a(com_hist birthyr) // keepsing
estimates store always_yob_ctr
qui sum index if e(sample)
scalar mean_y=r(mean)
estadd scalar mean_y
test frenchnat=germannat=other=other=speakfrench=hhold_head=hhold_size=0
scalar F_stat=r(p)
estadd scalar F_stat

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

// Fixed effects

estfe . *, labels(com_hist "Municipality (1936) FE" ct_1936_enc "\textit{Canton} FE" birthyr "Year-of-birth FE")
return list

// Labels

la var eligible 	"Born 1908-1927"
la var male 		"[0.3em] Male"
la var hhold_head 	"[0.3em] Household head"
la var speakfrench 	"[0.3em] French-speaking"
la var hhold_size 	"[0.3em] Household size"
la var age 			"[0.3em] Age"
la var age2			"[0.3em] Age $ \times $ Age"
la var germannat 	"[0.3em] German national"
la var frenchnat 	"[0.3em] French national"
la var protestant 	"[0.3em] Protestant"
la var other 		"[0.3em] Other religions"

// Table

estout OLS OLS_FE com_ctr eligible_ctr yob_ctr always_ctr always_yob_ctr ///
	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) ///
	title(Estimation strategy: Conscription determinants) ///
	drop(_cons 0._cons 0.com_hist 0.birthyr) ///
	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)} \\" /// 
	"\multicolumn{1}{l}{\textit{Dep. Variable}} &\multicolumn{7}{c}{Individual is conscripted}\\" /// 
	"\cmidrule(lr){2-8}" ///
	"\multicolumn{1}{l}{\textit{Sample}}&\multicolumn{3}{c}{Full sample (male)}	&\multicolumn{2}{c}{Eligible (male)}	&\multicolumn{2}{c}{Ineligible (male)}\\" /// 
	"\cmidrule(lr){2-4} \cmidrule(lr){5-6} \cmidrule(lr){7-8}" ///
	"\multicolumn{1}{l}{\textit{Specification}}&\multicolumn{1}{c}{No}			&\multicolumn{1}{c}{Within}		&\multicolumn{1}{c}{Within}		&\multicolumn{1}{c}{Within}		&\multicolumn{1}{c}{Within}	&\multicolumn{1}{c}{Within} 	&\multicolumn{1}{c}{Within}	\\" /// 
	"	&\multicolumn{1}{c}{controls} 	&\multicolumn{1}{c}{municipality} 	&\multicolumn{1}{c}{year-of-birth} 	&\multicolumn{1}{c}{municipality}	&\multicolumn{1}{c}{year-of-birth}	&\multicolumn{1}{c}{municipality}	&\multicolumn{1}{c}{year-of-birth}\\") /// 
	posthead("\hline" ///
	"\\") ///
	prefoot("") ///
	postfoot("\\")

estout OLS OLS_FE com_ctr eligible_ctr yob_ctr always_ctr always_yob_ctr ///
	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 F_stat, lab("Mean dep. variable" "Observations" "Clusters" "$ R $-squared" "Controls $ F $-test ($ p $-value)") fmt(3 %9.0fc 0 2 2)) /// 
	collabels(none) ///
	mlabels(, span none prefix(\multicolumn{@span}{c}{) suffix(})) ///
	msign(--) starlevels(* .1 ** .05 *** .01) ///
	drop(*) ///
	indicate("Municipality (1936) FE = 0.com_hist" ///	
	"Year-of-birth FE = 0.birthyr" ///
	, labels(Yes )) ///
	prehead("") ///
	posthead("") ///
	prefoot("" ///
	"\hline") ///
	postfoot("\hline" "\hline" ///
	"\end{tabular*}" /// 
	"\end{scriptsize}" ///
	"\begin{tablenotes}[normal,flushleft]" ///
	"\begin{scriptsize}" ///
	"\item \emph{Notes}:" /// 
	"OLS estimates of the likelihood of appearing in the \textit{Index of French Nationals Compelled into German Armed Forces} \citep{ministere1945basrhin, ministere1946moselle}. " ///
	"The unit of observation is a male individual. " ///
	"%Columns (1)-(3): all male individuals; " ///
	"%Columns (4) and (5): eligible males (born in 1908-1927); " ///
	"%Columns (6) and (7): ineligible males (not born in 1908-1927). " ///
	"%Municipality fixed effects are included in Columns (2) to (7). " ///
	"%Year-of-birth fixed effects are included in Columns (3), (5) and (7). " ///
	"Standard errors clustered at the year-of-birth-level in parentheses. " /// 
	"* significant at 10\%; ** at 5\%; *** at 1\%. " ///	
	"\end{scriptsize}" ///
	"\end{tablenotes}" ///
	"\end{threeparttable} " ///
	"\end{center}" ///
	"\end{table}")

cap log close
