library(readstata13) library(ggplot2) e65.per = read.dta13("./data/fem_ssa_period_e65.dta") e65.per[grepl("nomortadj",e65.per$scen), "Mortality.Adjustment"] = "Mortality Adjustment OFF" e65.per$Model = "Full Model" e65.per[grepl("minimal",e65.per$scen), "Model"] = "Minimal Model" table(e65.per$Model) e65.coh = read.dta13("./data/fem_ssa_cohort_e65.dta") e65.coh[grepl("mortadj2016",e65.coh$scen), "Mortality.Adjustment"] = "Mortality Adjustment 2016" e65.coh[grepl("mortadj2004",e65.coh$scen), "Mortality.Adjustment"] = "Mortality Adjustment 2004" e65.coh$Model = "Full Model" e65.coh[grepl("minimal",e65.coh$scen), "Model"] = "Minimal Model" for(male in 0:1) { sexlab = ifelse(male==1,"male","female") # Period LE plots # p = ggplot(e65.per[e65.per$male==male & e65.per$Mortality.Adjustment=="Mortality Adjustment OFF",], aes(x=rbyr,y=e65)) + # geom_line(aes(linetype=factor(series))) + # scale_linetype_manual(values=c("solid","longdash","longdash","twodash","twodash","dotted","dotted")) + # facet_grid(Model ~ .) + # labs(linetype="Projection method") + # xlab("Birth cohort") + ylab("e65") + # labs(title=paste0("Period life expectancy at age 65 for ",sexlab,"s"), subtitle="FEM vs. SSA assumptions") # ggsave(filename=paste0("./plots/period_e65_",sexlab,".pdf"),plot=p, device="pdf", height=8.5, width=11) # # coord_cartesian(xlim=c(1939,1953)) + # theme(legend.position="bottom") + # Cohort LE plots coh.plot = e65.coh[e65.coh$male==male & !is.na(e65.coh$Mortality.Adjustment) & e65.coh$Mortality.Adjustment=="Mortality Adjustment 2004" & !grepl("SSA 2001", e65.coh$series),] p = ggplot(coh.plot, aes(x=rbyr,y=e65)) + geom_line(aes(linetype=factor(series))) + scale_linetype_manual(values=c("solid","longdash","longdash","dotted","dotted")) + facet_grid(Model ~ .) + labs(linetype="Projection method") + xlab("Birth cohort") + ylab("e65") + labs(title=paste0("Cohort life expectancy at age 65 for ",sexlab,"s"), subtitle="FEM vs. SSA assumptions") ggsave(filename=paste0("./plots/cohort_e65_",sexlab,".pdf"),plot=p, device="pdf", height=8.5, width=11) # theme(legend.position="bottom") + }