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

622

Version

2.2.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Marius Pascariu

Last Published

May 5th, 2026

Functions in MortalityLaws (2.2.0)

MortalityLaw

Fit Mortality Laws
JPNregions

region codes
LifeTable

Compute Life Tables from Mortality Data
availableHMD

Check Data Availability in HMD
check_input_ReadAHMD

Check input ReadAHMD
HP4

Heligman-Pollard 4 Mortality Law - 9 parameters
ageMsg

What age(s) are we looking at?
HP3

Heligman-Pollard 3 Mortality Law - 9 parameters
check.MortalityLaw

Function to check input data in MortalityLaw
ReadHMD

Download The Human Mortality Database (HMD)
check_input_ReadCHMD

Check input for ReadCHMD
choose_optim

Run the optimisation routine
check_input_ReadHMD

Check input ReadHMD
check_input_ReadJMD

Check input ReadJMD
ReadHMD.core

Function to Download Data for a one Country
ahmd

MortalityLaws Test Data
df.residual.MortalityLaw

df.residual function for MortalityLaw
deviance.MortalityLaw

deviance function for MortalityLaw
MortalityLaws

MortalityLaws: Parametric Mortality Models, Life Tables and HMD
ReadAHMD

Download the Australian Human Mortality Database (AHMD)
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
availableLaws

Check Available Mortality Laws
availableLF

Check Available Loss Functions
ReadCHMD

Download the Canadian Human Mortality Database (CHMD)
makeham

Makeham Mortality Law - 1860
carriere1

Carriere Mortality Law - 1992
ggompertz

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

Make HTTP request
gompertz

Gompertz Mortality Law - 1825
carriere2

Carriere Mortality Law - 1992
compute.ax

Find ax indicator
find.my.case

Function that identifies the case/problem we have to solve
dx_lx

dx to lx
kannisto

Kannisto Mortality Law - 1998
summary.MortalityLaw

Summary MortalityLaw
plot.MortalityLaw

Plot Method for MortalityLaw
predict.MortalityLaw

Predict function for MortalityLaw
print.MortalityLaw

Print MortalityLaw
kannisto_makeham

Kannisto-Makeham Mortality Law - 1998
ReadJMD

Download the Japanese Mortality Database (JMD)
substrRight

Extracting the last n characters from a string
print.LifeTable

Print LifeTable
convertFx

Convert Life Table Indicators
print.summary.MortalityLaw

Print summary.MortalityLaw
beard

Beard Model - 1971
martinelle

Martinelle Model - 1987
addDetails

Retrieve model-specific details for fitting
kostaki

Kostaki Model - 1992
gompertz0

Gompertz Mortality Law - informative parameterization
makeham0

Makeham Mortality Law - informative parameterization
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
print.ReadAHMD

Print ReadCHMD
beard_makeham

Makeham-Beard Model - 1971
mx_qx

mx to qx
logLik.MortalityLaw

logLik function for MortalityLaw
data_format

Data formats
bring_parameters

Bring or Rename Starting Parameters in the Law Functions
quadratic

Quadratic Model
print.ReadCHMD

Print ReadCHMD
objective_fun

Objective function to minimise during optimisation
invgompertz

Inverse-Gompertz Mortality Law - informative parameterization
invweibull

Inverse-Weibull Mortality Law
rogersplanck

Rogers-Planck Model - 1983
wittstein

Wittstein Mortality Law - 1883
print.availableLaws

Print availableLaws
saveMsg

Print message when saving an object
thiele

Thiele Mortality Law - 1871
weibull

Weibull Mortality Law - 1939
print.availableLF

Print availableLF
uxAbove100

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

Strehler-Mildvan Model - 1960
opperman

Opperman Mortality Law - 1870
print.ReadHMD

Print ReadHMD
vandermaen

Van der Maen Model - 1943
siler

Siler Mortality Law - 1979
perks

Perks Model - 1932
vandermaen2

Van der Maen 2 Model - 1943
saveOutput

Save Output in the working directory
print.ReadJMD

Print ReadJMD
scale_x

Scale the age vector for stable optimisation
CANregions

Country codes
AUSregions

region codes
HP2

Heligman-Pollard 2 Mortality Law - 8 parameters
HP

Heligman-Pollard Mortality Law - 8 parameters - 1980
HMDindices

HMD Indices
HMDcountries

Country codes
JMD_sample

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

AIC function for MortalityLaw
AHMD_sample

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

Compute Life Tables from Parameters of a Mortality Law
HMD_sample

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

Check LifeTable input
CHMD_sample

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

LifeTable.core