View source: R/plot_life_exp.R
plot_life_exp | R Documentation |
This function plots the simulated period and/or cohort life
expectancies for a particular age, as retreived from the function
life_exp
, as a function of time.
plot_life_exp(le_yv, age, le_sim, sex, type, quantile, m_obs = NULL)
le_yv |
The vector of years. |
age |
The age. |
le_sim |
The simulated period and/or cohort life expectancies. |
sex |
Character vector. "Male" or "Female". |
type |
Character vector. Options are "per" and/or "coh". |
quantile |
The quantile of the confidence bound, e.g. "99%". |
m_obs |
Optional. The observed and closed death rates of the country of interest. |
The argument le_sim
should be the output of the function
life_exp
The argument m_obs
should be the output of the function
close_obs_death_rates
A ggplot representing the evolution and the uncertainty of the period and/or cohort life expectancy for a particular age and gender.
lst <- MultiMoMo::european_mortality_data xv <- 0:90 yv = yvSPEC <- 1988:2018 Countries <- names(lst$M$UNI) CountrySPEC <- "BE" lst <- get_data_specific_range(xv, yv, yvSPEC, lst, Countries, CountrySPEC) dat_M <- lst$M dat_F <- lst$F fit_M <- fit_li_lee(xv, yv, yvSPEC, CountrySPEC, dat_M, "NR", TRUE, FALSE) fit_F <- fit_li_lee(xv, yv, yvSPEC, CountrySPEC, dat_F, "NR", TRUE, FALSE) arima_spec <- list(K.t_M = "RWD", k.t_M = "AR3.1", K.t_F = "RWD", k.t_F = "AR5.0") n_ahead <- 52 + 120 n_sim <- 1000 est_method <- "PORT" proj_par <- project_parameters(fit_M, fit_F, n_ahead, n_sim, arima_spec, est_method) proj_rates <- project_mortality_rates(fit_M, fit_F, proj_par) kannisto_nages <- 30 kannisto_nobs <- 11 close_rates_M <- close_mortality_rates(yvSPEC, proj_rates$Male, kannisto_nages, kannisto_nobs) close_rates_F <- close_mortality_rates(yvSPEC, proj_rates$Female, kannisto_nages, kannisto_nobs) le_yv <- 1988:2070 le_ages <- c(0,65) le_type <- c("per", "coh") le_M <- life_exp(le_yv, le_type, le_ages, close_rates_M) m_obs_cl <- close_obs_death_rates(dat_M$UNI$BE$dtx, dat_M$UNI$BE$etx, kannisto_nages, kannisto_nobs) plot_life_exp(le_yv, 0, le_M, "Male", le_type, "99%", m_obs = m_obs_cl)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.