blc {BayesMortalityPlus} | R Documentation |
Lee-Carter Bayesian Estimation for mortality data
Description
Performs Bayesian estimation of the Lee-Carter model considering different variances for each age.
Usage
blc(Y, prior = NULL, init = NULL, M = 5000, bn = 4000, thin = 1)
Arguments
Y |
Log-mortality rates for each age. |
prior |
A list containing the prior mean |
init |
A list containing initial values for |
M |
The number of iterations. The default value is 5000. |
bn |
The number of initial iterations from the Gibbs sampler that should be discarded (burn-in). The default value is 4000. |
thin |
A Positive integer specifying the period for saving samples. The default value is 1. |
Details
Let Y_{it}
be the log mortality rate at age i
and time t
. The Lee-Carter
model is specified as follows:
Y_{it} = \alpha_i + \beta_i \kappa_t + \varepsilon_{it}, i=1,...,p
and t=1,...,T
,
where \alpha = (\alpha_1,...,\alpha_p)'
are the interept of the model that represent
the log-mortality rate mean in each age; \beta = (\beta_1,...,\beta_p)'
are the
coefficient regression that represent the speed of relative change in the log-mortality
rate in each age. \kappa = (\kappa_1,...,\kappa_T)'
are the state variable that
represent the global relative change in log-mortality rate. Finally, \varepsilon_{it} ~ N(0, \sigma^2_i)
is the random error.
For the state variable \kappa_t
Lee and Carter (1992) proposed a random walk with
drift to govern the dynamics over time:
\kappa_t = \kappa_{t-1} + \theta + \omega_t
,
where \theta
is the drift parameter and \omega_t
is the random error of the
random walk.
We implement the Bayesian Lee Carter (BLC) model, proposed by Pedroza (2006), to estimate
the model. In this approach, we take advantage of the fact that the Bayesian Lee Carter
can be specified as dynamic linear model, to estimate the state variables \kappa_t
through FFBS algorithm. To estimate the others parameters we use Gibbs sampler to sample
from their respective posterior distribution.
Value
A BLC
object.
alpha |
Posterior sample from alpha parameter. |
beta |
Posterior sample from beta parameter. |
phiv |
Posterior sample from phiv parameter. phiv is the precision of the random error of the Lee Carter model. |
theta |
Posterior sample from theta. |
phiw |
Posterior sample from phiw. phiw is the precision of the random error of the random walk. |
kappa |
Sampling from the state variables. |
Y |
Y Log-mortality rates for each age passed by the user to fit the model. |
bn |
The warmup of the algorithm specified by the user to fit the model. |
M |
The number of iterations specified by the user to fit the model. |
m0 |
The prior mean of kappa0. |
C0 |
The prior covariance matrix of kappa0. |
References
Lee, R. D., & Carter, L. R. (1992). “Modeling and forecasting US mortality.” Journal of the American statistical association, 87(419), 659-671.
Pedroza, C. (2006). “A Bayesian forecasting model: predicting US male mortality.” Biostatistics, 7(4), 530-550.
See Also
fitted.BLC()
, plot.BLC()
, print.BLC()
and predict.BLC()
for BLC
methods to native R functions fitted()
,
plot()
, print()
and predict()
.
expectancy.BLC()
and Heatmap.BLC()
for BLC
methods to compute and visualise the truncated life expectancy
via expectancy()
and Heatmap()
functions.
improvement()
to compute the improvement of each age, based on the resulting chains of the beta parameter.
Examples
## Example of transforming the dataset to fit the function:
## Importing mortality data from the USA available on the Human Mortality Database (HMD):
data(USA)
## Calculating the mortality rates for the general population:
require(dplyr)
require(tidyr)
require(magrittr)
USA %>% mutate(mx = USA$Dx.Total/USA$Ex.Total) -> data
data %>%
filter(Age %in% 18:80 & Year %in% 2000:2015) %>%
mutate(logmx = log(mx)) %>%
dplyr::select(Year,Age,logmx) %>%
pivot_wider(names_from = Year, values_from = logmx) %>%
dplyr::select(-Age) %>%
as.matrix() %>%
magrittr::set_rownames(18:80) -> Y
## Fitting the model
fit = blc(Y = Y, M = 100, bn = 20)
print(fit)
## Viewing the results
plot(fit, ages = 18:80)
plot(fit, parameter = "beta", ages=18:80)
improvement(fit)