## 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)
Run the code above in your browser using DataLab