expectancy.HP {BayesMortalityPlus}R Documentation

HP: Life expectancy

Description

This function computes the life expectancy for each age for Heligman-Pollard model.

Usage

## S3 method for class 'HP'
expectancy(
  x,
  Ex = NULL,
  age = NULL,
  graph = TRUE,
  max_age = 110,
  prob = 0.95,
  ...
)

Arguments

x

Object of the class HP or ClosedHP fitted by hp() or hp_close() functions.

Ex

Numeric vector with the exposure by age. This argument is only necessary when using poisson and binomial models with objects of the class HP.

age

Numeric vector specifying the ages to calculate the life expectancy. The default is a sequence (0, 10, 20, ...) until the last decade used in the fitted model.

graph

Logical value (TRUE ou FALSE). If TRUE, it returns a plot.

max_age

Positive number indicating the last age to be considered to compute the life expectancy (extrapolation will be considered to match the age interval if needed). This argument is only necessary with objects of the class HP.

prob

A percentage specifying the probability of credible interval.

...

Further arguments passed to or from other methods.

Value

A data.frame and (if graph = TRUE) a plot.

See Also

expectancy.DLM() and expectancy.BLC() for DLM and BLC methods.

Heatmap.HP() and Heatmap.list() for HP or list methods to drawing a Heatmap for the truncated life expectancy.

Examples

## Importing mortality data from the USA available on the Human Mortality Database (HMD):
data(USA)

# Example 1: --------------------------------

USA1990 = USA[USA$Year == 1990,]

Ex = USA1990$Ex.Total[1:91]
Dx = USA1990$Dx.Total[1:91]
x = 0:90

fit <- hp(x, Ex, Dx, model = "binomial", M = 1000, bn = 0, thin = 10)
expectancy(fit)


# Example 2: -------------------------------

# Using some arguments:

Ex = USA1990$Ex.Total[1:106]

expectancy(fit, Ex = Ex, age = c(0,20,30,60,105),
max_age = 105, prob = 0.99, graph = FALSE)



[Package BayesMortalityPlus version 0.2.3 Index]