predict.DLM {BayesMortalityPlus} | R Documentation |
Extrapolates the mortality curve fitted by DLM by calculating the median of death probability and the respective prediction interval.
## S3 method for class 'DLM'
predict(object, h, prob = 0.95, ...)
object |
A |
h |
The ages prediction horizon. |
prob |
Coverage probability of the predictive intervals. |
... |
Other arguments. |
A data.frame with the death probability prediction and prediction interval for the ages in the prediction horizon.
## Importing mortality data from the USA available on the Human Mortality Database (HMD):
data(USA)
## Selecting the log mortality rate of the year 2000, ranging from 0 to 100 years old:
USA2000 = USA[USA$Year == 2000,]
x = 0:100
Ex = USA2000$Ex.Total[x+1]
Dx = USA2000$Dx.Total[x+1]
mx_t = Dx/Ex
qx_t = 1 - exp(-mx_t)
y = log(qx_t)
## Fitting dlm
fit = dlm(y, M = 100, bn = 20, thin = 1)
## Extrapolating the death probabilities (qx)
predict(fit, h = 3, prob = 0.95)