The folder "projects/programs/rwalker/matt" contains code used to estimate life expectancies from the census microdata 

############ Life Expectancy Do Files ############

Each file "life_expectancy_estimation..." uses a different regression to estimate life expectancy. 
Intermediate and final outputs are saved with the do-files 'tag' (e.g. estimation3). These files are 
not necessary, but are more useful than tempfiles for debugging. 

All do-files files follow the same general procedure: 

1) Bring in ACS-SSA matched data, "/projects/programs/duquette/FromBrenden/datatemp/dtacr_20.dta"

2) Define 'groups' (e.g. birthyear x county x sex)

3) Estimate a gompertz function (mortality rate as a function of age). Including slope and intercept terms for the 
   variables that define a group means that each group has it's own hazard function. 
   
4) Use the gompertz function to estimate life ecpectancy: 
	-calculate l_a = product of (1-death rate) for years below age a
	-calculate L_a = (l_a + l_(a+1))/2. L_a is 'midpoint survivorship,'
	-calculate Life expectancy =sum(L_a*mpredicted*age)
	
The 4 models we estimate are:
	
estimation 1: 
glm m_a_raw i.coufip i.birthyr i.sex i.coufip#c.age i.sex#c.age i.birthyr#c.age, family(binomial) link(log) iterate(20)
	
estimation 2: 
glm m_a_raw i.coufip##c.age i.sex##c.age i.year##c.age, family(binomial) link(log) iterate(30)

estimation 3: 
glm m_a_raw i.coufip i.birthyr i.sex i.coufip#c.age i.sex#c.age, family(binomial) link(log) iterate(20)

estimation 4: 
glm m_a_raw i.coufip i.birthyr i.coufip#c.birthyr i.sex i.coufip#c.age i.sex#c.age i.birthyr#c.age, family(binomial) link(log) iterate(20)

	
############ Create Output Do File ############

This file creates life expectancy measures, then runs the 
necessary do-files to merge the life expectancy measures back 
onto census data, and generate output tables. It only calls 3 lines of code: 

* create new life expectancy measures:
do "/projects/programs/rwalker/matt/life_expectancy_estimation1.do"

*bring life expectancy measures through "newsubgroups" data creation chain 
do "/projects/disclosure/20181010/old/support/master_foodstamps_tarduno.do"

* run analysis:
do "/projects/disclosure/20181010/support/disclosure_tarduno.do"





	