Title: | Creating Actuarial Life Tables |
---|---|
Description: | Contains data and functions that can be used to make actuarial life tables. Each function adds a column to the inputted dataset for each intermediate calculation between mortality rate and life expectancy. Users can run any of our functions to complete the life table until that step, or run lifetable() to output a full life table that can be customized to remove optional columns. Methods for creating lifetables are as described in Zedstatistics (2021) <https://www.youtube.com/watch?v=Dfe59glNXAQ>. |
Authors: | Grace Rade [aut, cre, cph] |
Maintainer: | Grace Rade <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.0.9000 |
Built: | 2025-02-12 05:26:24 UTC |
Source: | https://github.com/g-rade/actlifer |
Adds a new column called CentralDeathRate to the dataset that was input. This column represents the central death rate of each age group - deaths/population.
central_death_rate(data, age, pop, deaths)
central_death_rate(data, age, pop, deaths)
data |
The mortality dataset, includes an age grouping variable, |
age |
The age grouping variable, must be categorical |
pop |
Population of each age group, must be numeric |
deaths |
The midyear number of deaths at each age group, must be numeric |
Data frame that was input with an added CentralDeathRate column.
# This function adds a CentralDeathRate column to the dataset central_death_rate(mortality2, "age_group", "population", "deaths")
# This function adds a CentralDeathRate column to the dataset central_death_rate(mortality2, "age_group", "population", "deaths")
Adds a new column called ConditionalProbDeath to the dataset that was input. This column represents the probability of death given the age group for each age group. In other words, the probability a person in a given age group will die before their next birthday.
conditional_death_prob(data, age, pop, deaths)
conditional_death_prob(data, age, pop, deaths)
data |
The mortality dataset, includes an age grouping variable |
age |
The age grouping variable, must be cateogrical |
pop |
Population of each age group, must be numeric |
deaths |
The number of deaths at each age group, must be numeric |
Data frame that was input with an added column, ConditionalProbDeath.
# This function will add a ConditionalProbDeath column to the dataset conditional_death_prob(mortality2, "age_group", "population", "deaths")
# This function will add a ConditionalProbDeath column to the dataset conditional_death_prob(mortality2, "age_group", "population", "deaths")
Adds a new column called ConditionalProbLife to the dataset that was input. ConditionalProbLife column contains the probabilities of surviving for each given age group. In other words, this is the probability of someone surviving to their next birthday.
conditional_life_prob(data, age, pop, deaths)
conditional_life_prob(data, age, pop, deaths)
data |
The mortality dataset, includes an age grouping variable |
age |
The age grouping variable, must be cateogrical |
pop |
Population of each age group, must be numeric |
deaths |
The number of deaths at each age group, must be numeric |
Dataset that was input with added columns ConditionalProbDeath and ConditionalProbLife. In other words, we are doing the "steps" up to the conditional probability of survival.
# This function will add the ConditionalProbDeath and ConditionalProbLife columns # to the dataset conditional_life_prob(mortality2, "age_group", "population", "deaths")
# This function will add the ConditionalProbDeath and ConditionalProbLife columns # to the dataset conditional_life_prob(mortality2, "age_group", "population", "deaths")
Checks inputs data, age, pop, and deaths to make sure they are valid.
input_check(data, age, pop, deaths)
input_check(data, age, pop, deaths)
data |
data frame input in the upper function |
age |
age string or character input in the upper function |
pop |
pop string or character input in the upper function |
deaths |
deaths string or character input in the upper function |
data frame with numeric pop and deaths columns
Adds a new column called LifeExpectancy to the dataset that was input. LifeExpectancy is how many more years we expect a person of age x to live beyond their current age.
life_expectancy(data, age, pop, deaths)
life_expectancy(data, age, pop, deaths)
data |
The mortality dataset, includes an age grouping variable, |
age |
The age grouping variable, must be categorical |
pop |
Population of each age group, must be numeric |
deaths |
The midyear number of deaths at each age group, must be numeric |
Dataset that was input with the added columns: ConditionalProbDeath, ConditionalProbLife, NumberToSurvive, PersonYears, TotalYears, and LifeExpectancy.
# This function will add the ConditionalProbDeath, ConditionalProbLife, # NumberToSurvive, PropToSurvive, PersonYears, TotalYears, and LifeExpectancy # columns to the dataset. # This will be a full lifetable life_expectancy(mortality2, "age_group", "population", "deaths")
# This function will add the ConditionalProbDeath, ConditionalProbLife, # NumberToSurvive, PropToSurvive, PersonYears, TotalYears, and LifeExpectancy # columns to the dataset. # This will be a full lifetable life_expectancy(mortality2, "age_group", "population", "deaths")
Gives user more control over their lifetable compared to the life_expectancy() function. Allows the user to add in the central death rate and proportion surviving to age x. Allows the user to omit accessory columns which are used to calculate life expectancy.
lifetable( data, age, pop, deaths, includeAllSteps = TRUE, includeCDR = TRUE, includePS = TRUE, ... )
lifetable( data, age, pop, deaths, includeAllSteps = TRUE, includeCDR = TRUE, includePS = TRUE, ... )
data |
The mortality dataset, includes an age grouping variable, |
age |
The age grouping variable, must be categorical |
pop |
Population of each age group, must be numeric |
deaths |
The midyear number of deaths at each age group, must be numeric |
includeAllSteps |
If false, will only include the proportion surviving to age x and life expectancy for age x |
includeCDR |
If true, will include the central death rate for each age group |
includePS |
If true, will include the proportion surviving for each age group |
... |
Other optional grouping variables (can be race, gender, etc.) |
Lifetable
# Running lifetable() and choosing not to include CentralDeathRate and # ProportionToSurvive (optional columns) in the output dataset lifetable(mortality2, "age_group", "population", "deaths", FALSE, TRUE, TRUE)
# Running lifetable() and choosing not to include CentralDeathRate and # ProportionToSurvive (optional columns) in the output dataset lifetable(mortality2, "age_group", "population", "deaths", FALSE, TRUE, TRUE)
A data extract takes from the CDC Wonder database.
mortality
mortality
A data frame with 85 rows of 3 columns representing the US population at mulit-year different age groups with which we use to make a life table. This data is from the year 2018
Categorical variable identifying each age group
the mid-year number of deaths in each age group
the US population of each age group
A data extract taken from the CDC Wonder database.
mortality2
mortality2
A data frame with 85 rows of 3 columns representing the deaths and US population at each single-year age group with which we can use to make a life table. This data is from the year 2016.
Categorical variable identifying each age group
the mid-year number of deaths in each age group
the US population of each age group
https://wonder.cdc.gov/ucd-icd10.html
A data extract taken from the CDC Wonder database.
mortality3
mortality3
A data frame with 170 rows of 4 columns representing the deaths and US population at each single-year age group for each sex with which we can use to make a life table. This data is from the year 2016.
Categorical variable identifying each age group
the mid-year number of deaths in each age group
the US population of each age group
a categroical variable grouping the data into male and female
<https://wonder.cdc.gov
Adds a new column called NumberToSurvive to the dataset that was input. NumberToSurvive represents the number of people living at the beginning of the given age interval, using an arbitrary 100,000 people for the first age group in the table.
number_to_survive(data, age, pop, deaths)
number_to_survive(data, age, pop, deaths)
data |
The mortality dataset, includes an age grouping variable, |
age |
The age grouping variable, must be categorical |
pop |
Population of each age group, must be numeric |
deaths |
The midyear number of deaths at each age group, must be numeric |
Dataset that was input with added columns: ConditionalProbDeath, ConditionalProbLife, and NumberToSurvive.
# This function will add the ConditionalProbDeath, ConditionalProbLife, and # NumberToSurvive columns to the dataset number_to_survive(mortality2, "age_group", "population", "deaths")
# This function will add the ConditionalProbDeath, ConditionalProbLife, and # NumberToSurvive columns to the dataset number_to_survive(mortality2, "age_group", "population", "deaths")
Adds a new column called PersonYears to the dataset that was input. PersonYears represents the number of years lived at age x based on the number surviving to age x.
person_years(data, age, pop, deaths)
person_years(data, age, pop, deaths)
data |
The mortality dataset, includes an age grouping variable, |
age |
The age grouping variable, must be categorical |
pop |
Population of each age group, must be numeric |
deaths |
The midyear number of deaths at each age group, must be numeric |
Dataset that was input with the added columns: ConditionalProbDeath, ConditionalProbLife, NumberToSurvive, PropToSurvive, PersonYears.
# This function will add the ConditionalProbDeath, ConditionalProbLife, # NumberToSurvive, PropToSurvive, and PersonYears columns to the dataset person_years(mortality2, "age_group", "population", "deaths")
# This function will add the ConditionalProbDeath, ConditionalProbLife, # NumberToSurvive, PropToSurvive, and PersonYears columns to the dataset person_years(mortality2, "age_group", "population", "deaths")
Adds a new column called PropToSurvive to the dataset that was input. PropToSurvive is the proportion surviving to age x
prop_to_survive(data, age, pop, deaths)
prop_to_survive(data, age, pop, deaths)
data |
The mortality dataset, includes an age grouping variable, |
age |
The age grouping variable, must be categorical |
pop |
Population of each age group, must be numeric |
deaths |
The midyear number of deaths at each age group, must be numeric |
Data frame that was input with columns for steps up to proportion surviving to age x included. That is, the original data with the following added columns: ConditionalProbDeath, ConditionalProbLife, NumberToSurvive, PropToSurvive
# This function will add the ConditionalProbDeath, ConditionalProbLife, # NumberToSbrvivem and PropToSurvive columns to the dataset prop_to_survive(mortality2, "age_group", "population", "deaths")
# This function will add the ConditionalProbDeath, ConditionalProbLife, # NumberToSbrvivem and PropToSurvive columns to the dataset prop_to_survive(mortality2, "age_group", "population", "deaths")
Adds a new column called TotalYears to the dataset that was input. TotalYears is the number of years lived from age zero to age x.
total_years_lived(data, age, pop, deaths)
total_years_lived(data, age, pop, deaths)
data |
The mortality dataset, includes an age grouping variable, |
age |
The age grouping variable, must be categorical |
pop |
Population of each age group, must be numeric |
deaths |
The midyear number of deaths at each age group, must be numeric |
Dataset that was input with the added columns: ConditionalProbDeath, ConditionalProbLife, NumberToSurvive, PersonYears, and TotalYears.
# This function will add the ConditionalProbDeath, ConditionalProbLife, # NumberToSurvive, PropToSurvive, PersonYearsm and TotalYears columns to the # dataset total_years_lived(mortality2, "age_group", "population", "deaths")
# This function will add the ConditionalProbDeath, ConditionalProbLife, # NumberToSurvive, PropToSurvive, PersonYearsm and TotalYears columns to the # dataset total_years_lived(mortality2, "age_group", "population", "deaths")