Learn R Programming

MortalityLaws: Parametric Mortality Models, Life Tables and HMD

Fit the most popular human mortality laws, and construct full and abridged life tables given various input indices. A mortality law is a parametric function that describes the dying-out process of individuals in a population during a significant portion of their life spans. For a comprehensive review of the most important mortality laws see Tabeau (2001). Function for downloading demographic data from the following sources are provided:

Installation

  1. Make sure you have the most recent version of R
  2. Run the following code in your R console
install.packages("MortalityLaws")

Updating to the latest version of the package

You can track and contribute to the development of MortalityLaws on GitHub. To install it:

  1. Install the release version of devtools from CRAN with install.packages("devtools").

  2. Make sure you have a working development environment.

    • Windows: Install Rtools.
    • Mac: Install Xcode from the Mac App Store.
    • Linux: Install a compiler and various development libraries (details vary across different flavors of Linux).
  3. Install the development version of MortalityLaws.

    devtools::install_github("mpascariu/MortalityLaws")

Help

All functions are documented in the standard way, which means that once you load the package using library(MortalityLaws) you can just type ?MortalityLaw to see the help file.

Copy Link

Version

Install

install.packages('MortalityLaws')

Monthly Downloads

716

Version

2.1.3

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Marius Pascariu

Last Published

April 16th, 2025

Functions in MortalityLaws (2.1.3)

LifeTable

Compute Life Tables from Mortality Data
LifeTable.core

LifeTable.core
LawTable

Compute Life Tables from Parameters of a Mortality Law
ReadCHMD

Download the Canadian Human Mortality Database (CHMD)
ReadHMD

Download The Human Mortality Database (HMD)
ReadAHMD

Download the Australian Human Mortality Database (AHMD)
ageMsg

What age(s) are we looking at?
HP4

Heligman-Pollard 4 Mortality Law - 9 parameters
ahmd

MortalityLaws Test Data
JPNregions

region codes
addDetails

Depending on the chosen mortality law, additional details need to be specified in order to be able to fit the models taking into account it's particularities.
ReadJMD

Download the Japanese Mortality Database (JMD)
bring_parameters

Bring or Rename Starting Parameters in the Law Functions
beard_makeham

Makeham-Beard Model - 1971
carriere1

Carriere Mortality Law - 1992
availableLF

Check Available Loss Function
availableHMD

Check Data Availability in HMD
availableLaws

Check Available Mortality Laws
beard

Beard Model - 1971
ReadHMD.core

Function to Download Data for a one Country
carriere2

Carriere Mortality Law - 1992
check_input_ReadAHMD

Check input ReadAHMD
df.residual.MortalityLaw

df.residual function for MortalityLaw
deviance.MortalityLaw

deviance function for MortalityLaw
check.MortalityLaw

Function to check input data in MortalityLaw
convertFx

Convert Life Table Indicators
dx_lx

dx to lx
find.my.case

Function that identifies the case/problem we have to solve
compute.ax

Find ax indicator
invgompertz

Inverse-Gompertz Mortality Law - informative parameterization
coale.demeny.ax

Find ax[1:2] indicators using Coale-Demeny coefficients Here we adjust the first two values of ax to account for infant mortality more accurately
invweibull

Inverse-Weibull Mortality Law
opperman

Opperman Mortality Law - 1870
make_http_request

Make HTTP request
kannisto_makeham

Kannisto-Makeham Mortality Law - 1998
data_format

Data formats
perks

Perks Model - 1932
print.ReadJMD

Print ReadJMD
kannisto

Kannisto Mortality Law - 1998
print.ReadHMD

Print ReadHMD
ggompertz

Gamma-Gompertz Model as in Vaupel et al. (1979)
gompertz

Gompertz Mortality Law - 1825
print.LifeTable

Print LifeTable
plot.MortalityLaw

Plot Function for MortalityLaw
predict.MortalityLaw

Predict function for MortalityLaw
print.availableLaws

Print availableLaws
print.availableLF

Print availableLF
print.MortalityLaw

Print MortalityLaw
rogersplanck

Rogers-Planck Model - 1983
gompertz0

Gompertz Mortality Law - informative parameterization
siler

Siler Mortality Law - 1979
saveMsg

Print message when saving an object
makeham

Makeham Mortality Law - 1860
quadratic

Quadratic Model
print.summary.MortalityLaw

Print summary.MortalityLaw
vandermaen2

Van der Maen 2 Model - 1943
uxAbove100

Educate mx or qx on how to behave above age 100 if it gets in trouble (with NA's, zero's and Inf)
vandermaen

Van der Maen Model - 1943
thiele

Thiele Mortality Law - 1871
check_input_ReadCHMD

Check input ReadHMD
mx_qx

mx to qx
strehler_mildvan

Strehler-Mildvan Model - 1960
head_tail

Summary function - display head and tail in a single data.frame The original code for this function was first written for 'psych' R package here we have modified it a bit
check_input_ReadJMD

Check input ReadAHMD
check_input_ReadHMD

Check input ReadHMD
logLik.MortalityLaw

logLik function for MortalityLaw
choose_optim

Select an optimizing method
objective_fun

Function to be Optimize
martinelle

Martinelle Model - 1987
kostaki

Kostaki Model - 1992
makeham0

Makeham Mortality Law - informative parameterization
saveOutput

Save Output in the working directory
weibull

Weibull Mortality Law - 1939
scale_x

Scaling method for x vector
print.ReadAHMD

Print ReadCHMD
wittstein

Wittstein Mortality Law - 1883
summary.MortalityLaw

Summary MortalityLaw
print.ReadCHMD

Print ReadCHMD
substrRight

Extracting the last n characters from a string
HMD_sample

HMD sample Data object generated by the ReadHMD() function.
CANregions

Country codes
JMD_sample

JMD sample Data object generated by the ReadJMD() function.
AIC.MortalityLaw

AIC function for MortalityLaw
HMDcountries

Country codes
HP

Heligman-Pollard Mortality Law - 8 parameters - 1980
AHMD_sample

AHMD sample Data object generated by the ReadAHMD() function.
CHMD_sample

CHMD sample Data object generated by the ReadCHMD() function.
HMDindices

HMD Indices
MortalityLaw

Fit Mortality Laws
MortalityLaws

MortalityLaws: Parametric Mortality Models, Life Tables and HMD
HP3

Heligman-Pollard 3 Mortality Law - 9 parameters
AUSregions

region codes
LifeTable.check

Check LifeTable input
HP2

Heligman-Pollard 2 Mortality Law - 8 parameters