expectancy.DLM {BayesMortalityPlus} | R Documentation |
DLM: Life expectancy
Description
This function computes the life expectancy for each age for Dynamic Linear model.
Usage
## S3 method for class 'DLM'
expectancy(
x,
age = seq(0, max(fit$info$ages), by = 10),
graph = TRUE,
max_age = 110,
prob = 0.95,
...
)
Arguments
x |
Object of the following classes: |
age |
Numeric vector specifying the ages to calculate the life expectancy. The default is a sequence (0, 10, 20, ...) until the last decade used in the fitted model. |
graph |
Logical value (TRUE ou FALSE). If TRUE, it also returns a plot. The default value is TRUE. |
max_age |
Positive number indicating the last age to be considered to compute the life expectancy (prediction will be considered to match the age interval if needed). This argument is only necessary with objects of the class |
prob |
A number specifying the probability of credible interval. The default value is 0.95. |
... |
Further arguments passed to or from other methods. |
Value
A data.frame and (if graph = TRUE) a plot.
See Also
expectancy.HP()
and expectancy.BLC()
for HP
and BLC
methods.
Heatmap.DLM()
and Heatmap.list()
for DLM
or list
methods to drawing a Heatmap for the truncated life expectancy.
Examples
## Importing mortality data from the USA available on the Human Mortality Database (HMD):
data(USA)
# Example 1: --------------------------------
USA1990 = USA[USA$Year == 1990,]
Ex = USA1990$Ex.Total[1:111]
Dx = USA1990$Dx.Total[1:111]
y <- log(Dx/Ex)
fit <- dlm(y, M = 100)
expectancy(fit)
# Example 2: -------------------------------
# Using some arguments:
expectancy(fit, age = c(0,20,30,60),
prob = 0.99, max_age = 90, graph = FALSE)