life_table: Calculate life expectancy

Description Usage Arguments Value Examples

View source: R/life_table.R

Description

Calculate life expectancy using the Chiang method

Usage

1
life_table(hazard, start_age, neonatal_deaths = TRUE)

Arguments

hazard

A numeric vector. The age specific hazard.

start_age

A numeric vector. The first age (in years) in each age group.

neonatal_deaths

Logical. Are neonatal deaths included?

Value

A data frame of:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Using an abridged set of population and mortality data:
head(abridged_data)
population <- subset(abridged_data,
                     time == 2011 & sex == "Persons" & measure == "Population",
                     select = c(age, value))
population = population$value
deaths <- subset(abridged_data,
                 time == 2011 & sex == "Persons" & measure == "Deaths",
                 select = c(age, value))
start_age <- as.numeric(gsub(" .+", "", deaths$age))
deaths  <- deaths$value
hazard <- deaths / population
life_table(hazard, start_age)

# Using single-year population and mortality data
head(single_year_data)
population <- subset(single_year_data,
                     time == 2011 & sex == "Persons" & measure == "Population",
                     select = c(age, value))
population = population$value
deaths <- subset(single_year_data,
                 time == 2011 & sex == "Persons" & measure == "Deaths",
                 select = c(age, value))
start_age <- as.numeric(gsub(" .+", "", deaths$age))
deaths  <- deaths$value
hazard <- deaths / population
life_table(hazard, start_age)

richardbroome2002/iomlifetR documentation built on Aug. 19, 2019, 10:26 p.m.