Learn R Programming

popstudy (version 1.0.0)

Lifetable: Life Table

Description

Estimates a lifetable from mortality rates and population data.

Usage

Lifetable(
  rates,
  pops,
  sex,
  max_age = NULL,
  first_year,
  threshold,
  jump,
  element = c("mx", "qx", "lx", "dx", "Lx", "Tx", "ex", "rx"),
  ...
)

Arguments

rates

character. A character string that specifies mortality data path. The dataset is a .txt file like CR_mortality_rates_2010_2015.

pops

character. A character string that specifies population data path. The dataset is a .txt file like CR_populations_1950_2015.

sex

character. "female" or "male".

max_age

numeric. Desire omega age. If NULL, Lifetable function takes the dataset's maximum age.

first_year

numeric. First year to start estimation.

threshold

numeric. Maximum forecast year.

jump

character. Same purpose to jumpchoice argument in forecast function.

element

character. Wanted estimation element, one of "mx", "qx", "lx", "dx", "Lx", "Tx", "ex" or "rx".

...

additional arguments to be passed to read.demogdata, such as label.

Value

Lifetable function returns a list with both data frames, wide and long format, for specified element in argument element for desire years.

References

Lifetablepopstudy

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
 write.table(CR_mortality_rates_2010_2015,
 file = "CR_mortality_rates_2010_2015.txt",
 sep = "\t", row.names = FALSE, quote = FALSE)

 write.table(CR_populations_1950_2015,
 file = "CR_populations_1950_2015.txt",
 sep = "\t", row.names = FALSE, quote = FALSE)

 Lifetable("CR_mortality_rates_2010_2015.txt", "CR_populations_1950_2015.txt",
 sex="female", first_year=2011, threshold=2150, jump="actual", max_age = 100,
 element="ex", label="CR")

# }

Run the code above in your browser using DataLab