Learn R Programming

⚠️There's a newer version (2.0.5) of this package.Take me there.

MortalityTables

Author: Reinhold Kainhofer, reinhold@kainhofer.com

R package implementing actuarial mortality tables (period and cohort life tables)

About the package

The MortalityTables package provides the mortalityTable base class and some derived classes to handle different types of mortality tables (also called life tables), mainly used for life insurance. Additionally it provides a plot function to compare multiple life tables either directly using the absolute mortalities in log-linear plots or using relative mortalities as percentages of a given reference table.

Types of Life Tables

Provided types of mortality tables are:

  • Base class : Class mortalityTable
  • Period life table : Class mortalityTable.period(ages, deathProbs, ..., baseYear=2000) : Death probabilities observed / predicted for one observation year; No dependency on the bith year is assumed.
  • Cohort life table using age-specific trends : Class mortalityTable.trendProjection : Death probabilities of a given base year are projected into the future using age-specific trends $\lambda_x$. The death probability of an $x$-year old in year baseYear + n is calculated as: $$q_x^{(baseYear+n)} = q_x^{(baseYear)} \cdot e^{-n\cdot\lambda_x}$$ : Consequently, the death probabilities for a person born in year YOB can be calculated as $$q_x^{YOB} = q_x^{(base)} \cdot e^{-(YOB+x-baseYear)\cdot \lambda_x}$$
  • Cohort life table approximation using age shift : Class mortalityTable.ageShift : Death probabilities for cohort $YOB$ are obtained by using death probabilities for cohort $X$ and modifying the technical age with a birth-year dependent shift: $$q_x^{YOB} = q_{x+shift(YOB)}^{(base)}$$
  • Mixed life table : Class mortalityTable.mixed : Arithmetic mean of two life tables with given weights. This approach is often used to generate unisex life tables by mixing male and female mortalities with given weights (e.g. 70:30 or 40:60)
  • Cohort life table using age-specific improvement factors : Class mortalityTable.improvementFactors : Project base life table using age-specific improvement factors.
  • Pension table : Class pensionTable : Four states: active, early retirement / invalidity, old-age pension, death (with optional widow) : All slots describe the corresponding transition probabilities by a : mortalityTable-derived object.

Loading the MortalityTables package

library("MortalityTables")

Provided Data Sets

The package provides several real-life life tables published by census bureaus and actuarial associations around the world. You can use the function mortalityTables.list to list all available datasets (if no argument is given) or all datasets that match the given pattern (wildcard character is *). You can then use mortalityTables.load to load either one single data set or all datasets that match the pattern.

# list all available data sets
mortalityTables.list()

# list all datasets for Austria
mortalityTables.list("Austria_*")

# Load the German annuity table DAV 2004-R
mortalityTables.load("Germany_Annuities_DAV2004R")

# Load all Austrian data sets
mortalityTables.load("Austria_*")

Further information

For further information on how to use the package, see the "Using the MortalityTables Package" vignette.

Copy Link

Version

Install

install.packages('MortalityTables')

Monthly Downloads

326

Version

2.0

License

GPL (>= 2)

Maintainer

Reinhold Kainhofer

Last Published

August 26th, 2020

Functions in MortalityTables (2.0)

deathProbabilities

Return the (cohort) death probabilities of the life table given the birth year (if needed)
MortalityTables-package

Provide life table classes for life insurance purposes
calculateImprovements

baseTable

Return the base table of the life table
PopulationData.AT2017

Austrian population count (exposure) and deaths in 2017
deathProbabilitiesIndividual

mT.extrapolateTrendExp

Extrapolate a mortality trend exponentially
mT.extrapolateProbsExp

Extrapolate base table of a mortalityTable using an exponential function
generateAgeShift

Generate data.frame containing age shifts for each birth year
getCohortTable

Return the cohort life table as a mortalityTable.period object
mT.translate

Translate base table of a cohort mortality table to a different observation year
baseYear

Return the base year of the life table
ageShift

Return the age shift of the age-shifted life table given the birth year
makeQxDataFrame

Converts one or multiple mortality table objects to a data frame that can be plotted by plotMortalityTables or plotMortalityTableComparisons
commutationNumbers

Calculate the commutation numbers for the given parameters, using the mortality table and an interest rate
lifeTable

Return the lifetable object (package lifecontingencies) for the cohort life table
mT.cleanup

Remove all non-essential data (raw data, etc.) from a mortalityTable object
mortalityTable.MakehamGompertz-class

Class mortalityTable.MakehamGompertz - Mortality table with Makeham-Gompertz's law
mortalityTable.zeroes

Generate a mortality table with all probabilities set to zero.
mortalityTable-class

Class mortalityTable
plot.mortalityTable

Plot multiple mortality tables (life tables) in one plot
plotMortalityTableComparisons

Plot multiple mortality tables (life tables) in one plot, relative to a given reference table
mortalityTables.load

pT.calculateTotalMortality

Calculate the total mortality of the pension table
mortalityTables.list

pensionTables.load

periodDeathProbabilities

Return the (period) death probabilities of the life table for a given observation year
mT.setDimInfo

Set additional information (year, description, type of risk, sex, etc.) for the mortality table.
fillAges

Fill the given probabilities with NA to match the desired age range.
ages

Return the defined ages of the life table
fitExpExtrapolation

Fit an exponential function exp(-A*(x-x0)) to the last value (f(100) and f'(100) need to coincide):
getOmega

Return the maximum age of the life table
mT.fillAges

Restrict/expand a mortalityTable to certain ages
mT.switchover

Switch over mortalities from one table to another at a given age
mT.setTrend

Set/Add a trend vector for the probabilities of the given mortalityTable object(s). Returns a mortalityTable.trendProjection object
mortalityTable.improvementFactors-class

Class mortalityTable.improvementFactors - Cohort life table with improvement factors
mortalityTable.jointLives-class

Class mortalityTable.jointLives - Life table for multiple joint lives
plotMortalityTables

Plot multiple mortality tables (life tables) in one plot
mT.fitExtrapolationLaw

Fit interpolation law to a mortality table and extrapolate
getPeriodTable

Return the period life table as a mortalityTable.period object
mortalityComparisonTable

Calculate relative mortalities for age bands and birth years
plotMortalityTrend

Plot the trends of multiple mortality tables (life tables) in one chart
mortalityTable.deMoivre-class

Class mortalityTable.deMoivre - Mortality table with de Moivre's law
mT.scaleProbs

Scale all probabilities of the given mortalityTable object(s) by the given factor
mortalityTable.ageShift-class

Class mortalityTable.ageShift - Cohort life tables generated by age-shift
mT.round

Round all components of a mortality table to the given number of digits
mortalityImprovement

Return the mortality trend (yearly log-death-probability improvement) of the given period or the given generation.
mortalityTable.observed-class

Class mortalityTable.observed - Life table from actual observations
mT.setName

Sets a new name for the given mortality table or the list/table/array of mortalityTables
mortalityTable.mixed-class

Class mortalityTable.mixed - Life table as a mix of two life tables
mortalityTable.period-class

Class mortalityTable.period - Period life tables
pensionTable-class

Class pensionTable
pensionTables.list

mortalityTable.trendProjection-class

Class mortalityTable.trendProjection - Cohort mortality table with age-specific trend
mortalityTable.NA

Empty mortality table indicating NA
whittaker.mortalityTable

Smooth a life table using the Whittaker-Henderson method, intepolation possibly missing values
undampenTrend

Return a mortalityTable.trendProjection object with the trend damping removed.
transitionProbabilities

Return all transition probabilities of the pension table (generational probabilities)
periodTransitionProbabilities

Return all period transition probabilities of the pension table
periodDeathProbabilitiesIndividual

mortalityTable.once

Generate a (deterministic) mortality table with only one probability set to 1 (for the given age)
mortalityTable.onceAndFuture

Generate a (deterministic) mortality table with all probabilities starting at a given age set to 1
pT.getSubTable

Extract a sub-table from a pensionTable
mortalityTable.Weibull-class

Class mortalityTable.Weibull - Mortality table with Weibull's law
pT.setDimInfo

Set additional information (year, description, type of risk, sex, etc.) for the pension table.
setLoading

Return a copy of the table with an additional loading added
setModification

Return a copy of the table with the given modification function added