Given a data frame with dates, sex and mortality data by age (rates, conditioned probabilities of death or survival function), this function interpolate/extrapolate life tables using the method for limited data suggested by Li et. al (2004) (at least three observed years).
interp_lc_lim( input = NULL, dates_out = dates_in, Single = FALSE, dates_e0 = NULL, e0_Males = NULL, e0_Females = NULL, prev_divergence = FALSE, OAG = TRUE, verbose = TRUE, SVD = FALSE, ... )
input | data.frame with cols: Date, Sex, Age, nMx (opt), nqx (opt), lx (opt) |
---|---|
dates_out | numeric. Vector of decimal years to interpolate or extrapolate. |
Single | logical. Whether or not the lifetable output is by single ages. |
dates_e0 | numeric. Vector of decimal years where |
e0_Males | numeric. Vector of life expectancy by year to be fitted. Same length than |
e0_Females | numeric. Vector of life expectancy by year to be fitted. Same length than |
prev_divergence | logical. Whether or not prevent divergence and sex crossover. Default |
OAG | logical. Whether or not the last element of |
verbose | logical. Default |
SVD | logical. Use Singular Value Decomposition for estimate b and k or Maximum Likelihood Estimation. Default |
... | Other arguments to be passed on to the |
List with:
Interpolated/extrapolated lifetables in a data.frame with columns:
Date
numeric. Dates included in dates_out,
Sex
character. Male "m"
or female "f"
,
Age
integer. Lower bound of abridged age class,
`AgeInt`` integer. Age class widths.
nMx
numeric. Age-specific central death rates.
nAx
numeric. Average time spent in interval by those deceased in interval.
nqx
numeric. Age-specific conditional death probabilities.
lx
numeric. Lifetable survivorship
ndx
numeric. Lifetable deaths distribution.
nLx
numeric. Lifetable exposure.
Sx
numeric. Survivor ratios in uniform 5-year age groups.
Tx
numeric. Lifetable total years left to live above age x.
ex
numeric. Age-specific remaining life expectancy.
List with estimated Lee-Carter parameters for each sex:
kt
numeric time vector. Time trend in mortality level.
ax
numeric age vector. Average time of log(m_{x,t})
.
bx
numeric age vector. Pattern of change in response to kt
.
Based on spreadsheet "Li_2018_Limited_Lee-Carter-v4.xlsm" from UN.
Useful for abridged or single ages, and allows output in both formats also.
One option is the use of non-divergent method for sex coherency (Li & Lee, 2005).
The other is the possibility of fitting "k"
to replicate "e_0"
at some given dates.
Draft Version
Li N, Lee R (2005). “Coherent mortality forecasts for a group of populations: An extension of the Lee-Carter method.” Demography, 42(3), 575. doi: 10.1353/dem.2005.0021 . Li N, Lee R, Tuljapurkar S (2004). “Using the Lee-Carter Method to Forecast Mortality for Populations with Limited Data\(\ast\).” Int. Stat. Rev., 72(1), 19--36. ISSN 0306-7734, doi: 10.1111/j.1751-5823.2004.tb00221.x .
# mortality rates from Sweden, for specific dates # needs mortality rates in this dates: dates_out <- as.Date(paste0(seq(1948,2018,5),"-07-01")) # apply LC with limited data to extrap/interpolate lc_lim_data <- interp_lc_lim(input = mA_swe, dates_out = dates_out, OAG = FALSE)$lt_hat if (FALSE) { lc_lim_data %>% ggplot(aes(Age,nMx,col=factor(round(Date,1)))) + geom_step() + scale_color_viridis_d() + scale_y_log10() + theme_classic() + facet_wrap(~Sex) } # with simple ages as output lc_lim_data_single <- interp_lc_lim(input = mA_swe, dates_out = dates_out, OAG = FALSE, Single = TRUE)$lt_hat if (FALSE) { lc_lim_data_single %>% ggplot(aes(Age,nMx,col=factor(round(Date,1)))) + geom_step() + scale_color_viridis_d() + scale_y_log10() + theme_classic() + facet_wrap(~Sex) } # Avoiding cross-over between sex. lc_lim_nondiv <- interp_lc_lim(input = mA_swe, dates_out = dates_out, OAG = FALSE, prev_divergence = TRUE)$lt_hat if (FALSE) { lc_lim_nondiv %>% ggplot(aes(Age,nMx,col=factor(round(Date,1)))) + geom_step() + scale_color_viridis_d() + scale_y_log10() + theme_classic() + facet_wrap(~Sex) } # Fitting information about e0 in Sweden for past years. lc_lim_fite0 <- interp_lc_lim(input = mA_swe, dates_out = dates_out, OAG = FALSE, dates_e0 = unique(e0_swe$Date), e0_Males = e0_swe$e0[e0_swe$Sex=="m"], e0_Females = e0_swe$e0[e0_swe$Sex=="f"])$lt_hat if (FALSE) { ggplot() + geom_point(data = e0_swe, aes(Date,e0,col=factor(Sex)))+ geom_line(data = lc_lim_fite0[lc_lim_fite0$Age==0,], aes(Date,ex,col=factor(Sex)))+ labs(color = "Sex")+ theme_classic() } # smooth and/or extend open age group, in this case input is for 80+, and chosen law is Makeham. lc_lim_extOAg <- interp_lc_lim(input = mA_swe[mA_swe$Age<=80,], dates_out = dates_out, OAG = FALSE, OAnew=100, extrapLaw = "makeham")$lt_hat if (FALSE) { ggplot() + geom_step(data = lc_lim_extOAg, aes(Age,nMx,col=factor(round(Date,1)))) + scale_y_log10() + scale_color_viridis_d() + theme_classic() + facet_wrap(~Sex) } #End