dlm {BayesMortalityPlus} | R Documentation |

## Dynamic Linear Model for mortality table graduation

### Description

This function fits a Dynamic Linear Model (DLM) for mortality data following a Bayesian framework using Forward Filtering Backward Sampling algorithm to compute the posterior distribution. The response variable is the log of the 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.

### Usage

```
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, b = 0), M = 2000, ages = 0:(length(y)-1))
```

### Arguments

`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 real value or real vector of the same length as y with values in the '(0, 1)' interval specifying the discount factor for each age. A higher value of delta results in a higher smoothness of the fitted curve. If a single value is defined, this same value is used for all ages. 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 that indicates the sampling size from the posterior distributions. The default value is 2000. |

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

### Details

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, \sigma^2)`

and `w_t \sim N(0, \sigma^2 W_t)`

. We
use the discount factors `\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). `\delta`

can be specified as a single value for all ages
or as a vector in which each element is associated with an age.

A scheme described by (Petris et al, 2009) for conjugated inference is used. For more details, see (Petris et al, 2009).

### Value

A DLM class object.

`mu` |
Posterior samples from |

`theta` |
Posterior samples from |

`sig2` |
Posterior samples from |

`param` |
A list with the states parameters for filtering distribution (mt, Ct), predictive distribution (ft, Qt), smoothing distribution (as, Rs), and parameters of the posterior distribution for variance (alpha, beta). |

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

### References

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

### See Also

`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.

### Examples

```
## 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)
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]"))
## Varying discount factor
fit2 = dlm(y, delta = c(rep(0.8, 36), rep(0.9, 65)))
plot(fit2)
```

*BayesMortalityPlus*version 0.2.4 Index]