maple: maple: model averaged projections of life expectancy maple is...

Description Usage Arguments Value Note Examples

View source: R/maple.R

Description

maple: model averaged projections of life expectancy maple is an R package for fitting statistical models on demographic data to produce projections of death rates and life expectancy.

Produce model averaged projections of death rates and life expectancy.

Usage

1
2
3
maple(deaths, population, forecast.horizon, holdout, models = maple_models(),
  num.draws = 1000, ax = NULL,
  num.threads = inla.getOption("num.threads"), verbose = TRUE)

Arguments

deaths

A matrix of death counts, with 18 rows, one for each 5-year age group 0-4, ..., 80-84, 85+ and one column for each year of available data. The column names of the matrix must be the years of data.

population

A matrix of mid-year population numbers, in the same row/column format as deaths.

forecast.horizon

The number of years to produce projections for.

holdout

The number of years of data to hold out to calculate model weights.

models

The individual models to be run and averaged; see ?maple_models for more details.

num.draws

The number of posterior samples from individual model fits to use for producing the BMA estimates.

ax

The number of years lived on average by those who die in their current age group. See ?maple_plt for more details.

num.threads

The number of threads to use when running the models. This is passed to the INLA methods. If not specified, then all available threads are used.

verbose

If TRUE (the default), print some information on progress fitting models, etc.

Value

A list with the following entries

model.weights

The weights used to combine models into the model average.

sample.summaries

A data frame holding statistical summary information for age-specific death rates, life expectancy and probability of dying, calculated from the posterior draws.

samples

A list of life table draws, calculated using posterior samples of death rates.

individual.model.sample.summaries

A data frame containing predictions under individual models.

Note

The maximum possible number of BMA samples is taken, depending on the model weights. For example if num.draws == 1000 and there are 5 models with weights 0.25, 0.2, 0.2, 0.2, and 0.15, the code will try to use all draws from the first model (with largest weight) and a number of draws from the remaining models inversely proportional to their weights (800, 800, 800, 600).

Examples

1
2
3
4
5
6
7
data(maple.deaths)
data(maple.population)
data(maple.ax)
models <- maple_models()[c(1, 20)]
bma <- maple(deaths = maple.deaths, population = maple.population,
             forecast.horizon = 20, holdout = 13, models = models,
             ax = maple.ax)

vkontis/maple documentation built on July 15, 2019, 5:08 p.m.