Fit and Forecast Bayesian CBD model. The model can be fitted with a Poisson or Negative-Binomial distribution. The function outputs posteriors distributions for each parameter, predicted death rates and log-likelihoods.

cbd_stan(
  death,
  exposure,
  age,
  forecast,
  validation = 0,
  family = c("poisson", "nb"),
  ...
)

Arguments

death

Matrix of deaths.

exposure

Matrix of exposures.

age

Vector of ages.

forecast

Number of years to forecast.

validation

Number of years for validation.

family

specifies the random component of the mortality model. "Poisson" assumes a Poisson model with log link and "nb" assumes a negative-binomial model with log link and overdispersion parameter \(\phi\).

...

Arguments passed to rstan::sampling (e.g. iter, chains).

Value

An object of class stanfit returned by rstan::sampling

Details

The created model is either a log-Poisson or a log-Negative-Binomial version of the CBD model: $$D_{x,t} \sim \mathcal{P}(\mu_{x,t} e_{x,t})$$ or $$D_{x,t}\sim NB\left(\mu_{x,t} e_{x,t},\phi\right)$$ with $$\log \mu_{xt} = \kappa_t^{(1)} + (x-\bar{x})\kappa_t^{(2)},$$ where \(\bar{x}\) is the average age in the data.

For the period terms, we consider a multivariate random walk with drift: $$\boldsymbol{\kappa}_{t}=\boldsymbol{c}+\boldsymbol{\kappa}_{t-1}+\boldsymbol{\epsilon}_{t}^{\kappa},\quad \bm{\kappa}_{t}=\left(\begin{array}{c}\kappa_{t}^{(1)} \\\kappa_{t}^{(2)}\end{array}\right), \quad \boldsymbol{\epsilon}_{t}^{\kappa} \sim N\left(\mathbf{0}, \Sigma\right),$$ with normal priors: \(\boldsymbol{c} \sim N(0,10)\).

The variance-covariance matrix of the error term is defined by $$\boldsymbol{\Sigma}=\left(\begin{array}{cc}\sigma_1^{2} & \rho_{\Sigma} \sigma_1 \sigma_2 \\\rho_{\Sigma} \sigma_1 \sigma_{Y} & \sigma_2^{2}\end{array}\right)$$ where the variance coefficients have independent exponential priors: \(\sigma_1, \sigma_2 \sim Exp(0.1)\) and the correlation parameter has a uniform prior: \(\rho_{\Sigma} \sim U\left[-1,1\right]\). As for the other models, the overdispersion parameter has a prior distribution given by $$\frac{1}{\phi} \sim Half-N(0,1).$$

References

Cairns, A. J. G., Blake, D., & Dowd, K. (2006). A Two-Factor Model for Stochastic Mortality with Parameter Uncertainty: Theory and Calibration. Journal of Risk and Insurance, 73(4), 687-718.

Examples



#10-year forecasts for French data for ages 50-90 and years 1970-2017 with a log-NB model
ages.fit<-50:90
years.fit<-1970:2017
deathFR<-FRMaleData$Dxt[formatC(ages.fit),formatC(years.fit)]
exposureFR<-FRMaleData$Ext[formatC(ages.fit),formatC(years.fit)]
iterations<-50 # Toy example, consider at least 2000 iterations
fitCBD=cbd_stan(death = deathFR,exposure=exposureFR, age=ages.fit, forecast = 10,
family = "poisson",iter=iterations,chains=1)
#> 
#> SAMPLING FOR MODEL 'CBDmodel' NOW (CHAIN 1).
#> Chain 1: 
#> Chain 1: Gradient evaluation took 0.001 seconds
#> Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 10 seconds.
#> Chain 1: Adjust your expectations accordingly!
#> Chain 1: 
#> Chain 1: 
#> Chain 1: WARNING: There aren't enough warmup iterations to fit the
#> Chain 1:          three stages of adaptation as currently configured.
#> Chain 1:          Reducing each adaptation stage to 15%/75%/10% of
#> Chain 1:          the given number of warmup iterations:
#> Chain 1:            init_buffer = 3
#> Chain 1:            adapt_window = 20
#> Chain 1:            term_buffer = 2
#> Chain 1: 
#> Chain 1: Iteration:  1 / 50 [  2%]  (Warmup)
#> Chain 1: Iteration:  5 / 50 [ 10%]  (Warmup)
#> Chain 1: Iteration: 10 / 50 [ 20%]  (Warmup)
#> Chain 1: Iteration: 15 / 50 [ 30%]  (Warmup)
#> Chain 1: Iteration: 20 / 50 [ 40%]  (Warmup)
#> Chain 1: Iteration: 25 / 50 [ 50%]  (Warmup)
#> Chain 1: Iteration: 26 / 50 [ 52%]  (Sampling)
#> Chain 1: Iteration: 30 / 50 [ 60%]  (Sampling)
#> Chain 1: Iteration: 35 / 50 [ 70%]  (Sampling)
#> Chain 1: Iteration: 40 / 50 [ 80%]  (Sampling)
#> Chain 1: Iteration: 45 / 50 [ 90%]  (Sampling)
#> Chain 1: Iteration: 50 / 50 [100%]  (Sampling)
#> Chain 1: 
#> Chain 1:  Elapsed Time: 0.08 seconds (Warm-up)
#> Chain 1:                0.089 seconds (Sampling)
#> Chain 1:                0.169 seconds (Total)
#> Chain 1: