robjhyndman / demography

demography package for R
https://pkg.robjhyndman.com/demography
73 stars 25 forks source link

age limits in e0 #9

Open robjhyndman opened 10 years ago

robjhyndman commented 10 years ago

A couple of refinements needed for e0 calculations - to do with minimum and maximum ages for life table calculations.

Usage

life.expectancy(data, series = names(data$rate)[1], years = data$year, type = c("period", "cohort"), age = min(data$age), max.age = min(100, max(data$age))) flife.expectancy(data, series=NULL, years = data$year, type = c("period", "cohort"), age = min(data$age), max.age = NULL, PI = FALSE, nsim = 500, ...) e0(data, series = NULL, years = data$year, type = c("period", "cohort"), max.age = NULL, PI = FALSE, nsim = 500, ...)

lifetable(data, series = names(data$rate)[1], years = data$year, ages = data$age, max.age = min(100, max(data$age)), type = c("period", "cohort"))

MINIMUM AGE is picked up from data in life.expectancy() and flife.expectancy() parameters but this is not used in e0()

e0 function (data, series = NULL, years = data$year, type = c("period", "cohort"), max.age = NULL, PI = FALSE, nsim = 500, ...) { flife.expectancy(data, series = series, years = years, age = 0, type = type, max.age = max.age, PI = PI, nsim = nsim, ...) }

MAXIMUM AGE is not allowed to be greater than 100 by virtue of max.age = min(100, max(data$age) in life.expectancy() and lifetable

If the user is happy with the smoothed rates at 110+, there is no reason not to allow the life table and life expectancy to use data to 110+. So specifying a max.age of 110 does not result in a forecast at ages 0-110+.

Grateful if specified minimum and maximum ages are carried through. Thanks