/** compute standardized mortality rate for FEM mortality using HRS as reference population */ global scen : env SCEN log using logs/${scen}_hrs_smr.log, replace * prepare HRS mortality rates for comparison clear forvalues yr=2005/2012 { append using ../hrs_mortality_validation/data/weighted_hrsdeath_mortality`yr'.dta } keep year dx Lx male age desc drop if age < 55 rename age agegrp collapse (sum) dx Lx, by(year agegrp male ) * collapse to 2-year mortality in even years gen birthcohort = year - agegrp sort male birthcohort agegrp # 2-year mortality rate = (num. of deaths in years 1 and 2) / (approx. exposure time in years 1 and 2) gen mx2yr = (dx[_n-1] + dx) / (Lx[_n-1] + Lx) if mod(year, 2)==0 & age > 55 * drop odd years for merging with FEM results drop if mod(year,2)==1 tempfile hrs_rates save `hrs_rates' * merge FEM and CDC rates for comparison use data/${scen}_mortality_rates.dta sort year male agegrp merge 1:1 year male agegrp using `hrs_rates' keep if _merge==3 * save age-specific 2-year mortality probabilities for plotting save data/${scen}_hrs_mortbyage.dta, replace gen expdied = exposure * mx2yr egen agebin = cut(agegrp), at(40,55,65,75,85,125) collapse (sum) n_died expdied, by(male year agebin) gen smr = n_died / expdied sort male agebin year li save data/${scen}_hrs_smr.dta, replace