dlm {BayesMortalityPlus} | R Documentation |

This function fits a Dynamic Linear Model (DLM) for mortality data following a Bayesian framework using Forward Filtering Backward Sampling algorithm and Markov chain Monte Carlo Gibbs sampler to compute the posterior distribution. The response variable is the log of mortality rate, and it is modeled specifying the matrices Ft and Gt from the DLM equations. Furthermore, the discount factor is used to control the smoothness of the fitted model. By default, a linear growth model is specified.

```
dlm(y, Ft = matrix(c(1,0), nrow = 1), Gt = matrix(c(1,0,1,1), 2),
delta = 0.85, prior = list(m0 = rep(0, nrow(Gt)), C0 = diag(100, nrow(Gt))),
prior.sig2 = list(a = 0.01, b = 0.01), M = 5000, bn = 3000, thin = 1,
ages = 0:(length(y)-1))
```

`y` |
Numeric vector of log mortality rates. |

`Ft` |
1xp Matrix that specifies the observation equation, where p is the number of parameters. By default, 'Ft = matrix(c(1,0), nrow = 1)'. |

`Gt` |
pxp Matrix that specifies the system equations. By default, Gt = matrix(c(1,0,1,1), 2). |

`delta` |
Positive number in '(0, 1)' interval specifying the discount factor. A higher value of delta results in a higher smoothness of the fitted curve. By default, delta is '0.85'. |

`prior` |
A list with the prior mean vector |

`prior.sig2` |
A list with the prior parameters (a, b) of Inverted Gamma distribution for |

`M` |
Positive integer indicating the number of iterations of the MCMC run. |

`bn` |
Non-negative integer indicating the number of iteration to be discarded as the burn-in period. |

`thin` |
Positive integer specifying the period for saving samples. |

`ages` |
Numeric vector of the ages fitted. Default is '0:(length(y)-1)'. |

Let `Y_t`

be the log mortality rate at age `t`

. A DLM is specified as follows:

For `t = 0`

:

`\theta_0 \sim N_p (m_0, C_0)`

Now, for `t \geq 1`

:

The observation equation:

`Y_t = F_t \theta_t + v_t`

The system equation:

`\theta_t = G_t \theta_{t-1} + w_t`

Where `F_t`

and `G_t`

are known matrices. `v_t`

and `w_t`

are independent
random errors with `v_t \sim N(0, V_t)`

and `w_t \sim N(0, W_t)`

. Assumes
`V_t = \sigma^2 V^{'}`

, constant for all ages `t`

and `V^{'}`

known. We use
the discount factor `\delta`

to specify `W_t`

as `W_t = C_T(1-\delta)/\delta`

,
where `C_t`

is the conditional covariance matrix of `\theta_t`

. So, if `\delta = 0`

there is no loss information as `t`

increase (completely reducing the smoothness of
the fitted curve).

To adjust the model adopted a scheme described by (Petris et al, 2009) that uses the FFBS algorithm and a Gibbs sampler step to sample from the parameters of the posterior distribution. For more details, see (Petris et al, 2009).

A DLM class object.

`mu` |
Posterior samples from |

`theta` |
Posterior samples from |

`sig2` |
Posterior samples from |

`Wt` |
Posterior samples from matrices |

`info` |
A list with some informations of the fitted model: the specification of |

Campagnoli, P., Petris, G., and Petrone, S. (2009). *Dynamic linear models with R*. Springer-Verlag New York.

`fitted.DLM()`

, `predict.DLM()`

, `plot.DLM()`

, `print.DLM()`

and `summary.DLM()`

for `DLM`

methods to native R functions `fitted()`

,
`plot()`

, `print()`

and `summary()`

.

`expectancy.DLM()`

and `Heatmap.DLM()`

for `DLM`

methods to compute and visualise the truncated life expectancy
via `expectancy()`

and `Heatmap()`

functions.

`dlm_close()`

for close methods to expand the life tables.

`plot_chain()`

to visualise the markov chains, respectively.

```
## Importing mortality data from the USA available on the Human Mortality Database (HMD):
data(USA)
## Selecting the log mortality rate of the 2010 male population ranging from 0 to 100 years old
USA2010 = USA[USA$Year == 2010,]
x = 0:100
Ex = USA2010$Ex.Male[x+1]
Dx = USA2010$Dx.Male[x+1]
y = log(Dx/Ex)
## Fitting DLM
fit = dlm(y, M = 100, bn = 20, thin = 1)
print(fit)
summary(fit)
## Using other functions available in the package:
## plotting (See "?plot.DLM" in the BayesMortality package for more options):
plot(fit)
## qx estimation (See "?fitted.DLM" in the BayesMortality package for more options):
fitted(fit)
## chain's plot (See "?plot_chain" for more options):
plot_chain(fit, param = c("mu[0]", "mu[100]"))
```

[Package *BayesMortalityPlus* version 0.1.1 Index]