Learn R Programming

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

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

891

Version

2.1.2

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Marius Pascariu

Last Published

April 2nd, 2025

Functions in MortalityLaws (2.1.2)

LifeTable.core

LifeTable.core
MortalityLaws

MortalityLaws: Parametric Mortality Models, Life Tables and HMD
MortalityLaw

Fit Mortality Laws
LifeTable

Compute Life Tables from Mortality Data
JPNregions

region codes
JMD_sample

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

Heligman-Pollard 4 Mortality Law - 9 parameters
ReadHMD

Download The Human Mortality Database (HMD)
ReadCHMD

Download the Canadian Human Mortality Database (CHMD)
ageMsg

What age(s) are we looking at?
availableHMD

Check Data Availability in HMD
availableLF

Check Available Loss Function
ReadAHMD

Download the Australian Human Mortality Database (AHMD)
ahmd

MortalityLaws Test Data
ReadHMD.core

Function to Download Data for a one Country
ReadJMD

Download the Japanese Mortality Database (JMD)
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.
availableLaws

Check Available Mortality Laws
beard

Beard Model - 1971
beard_makeham

Makeham-Beard Model - 1971
bring_parameters

Bring or Rename Starting Parameters in the Law Functions
carriere1

Carriere Mortality Law - 1992
convertFx

Convert Life Table Indicators
data_format

Data formats
carriere2

Carriere Mortality Law - 1992
deviance.MortalityLaw

deviance function for MortalityLaw
df.residual.MortalityLaw

df.residual function for MortalityLaw
ggompertz

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

Gompertz Mortality Law - 1825
check_input_ReadHMD

Check input ReadHMD
check_input_ReadCHMD

Check input ReadHMD
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
compute.ax

Find ax indicator
logLik.MortalityLaw

logLik function for MortalityLaw
kostaki

Kostaki Model - 1992
kannisto

Kannisto Mortality Law - 1998
choose_optim

Select an optimizing method
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
invgompertz

Inverse-Gompertz Mortality Law - informative parameterization
opperman

Opperman Mortality Law - 1870
print.availableLF

Print availableLF
gompertz0

Gompertz Mortality Law - informative parameterization
check_input_ReadJMD

Check input ReadAHMD
martinelle

Martinelle Model - 1987
invweibull

Inverse-Weibull Mortality Law
check.MortalityLaw

Function to check input data in MortalityLaw
makeham0

Makeham Mortality Law - informative parameterization
kannisto_makeham

Kannisto-Makeham Mortality Law - 1998
perks

Perks Model - 1932
quadratic

Quadratic Model
saveMsg

Print message when saving an object
check_input_ReadAHMD

Check input ReadAHMD
siler

Siler Mortality Law - 1979
summary.MortalityLaw

Summary MortalityLaw
dx_lx

dx to lx
print.LifeTable

Print LifeTable
print.MortalityLaw

Print MortalityLaw
substrRight

Extracting the last n characters from a string
thiele

Thiele Mortality Law - 1871
print.availableLaws

Print availableLaws
uxAbove100

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

Make HTTP request
rogersplanck

Rogers-Planck Model - 1983
objective_fun

Function to be Optimize
find.my.case

Function that identifies the case/problem we have to solve
print.summary.MortalityLaw

Print summary.MortalityLaw
mx_qx

mx to qx
strehler_mildvan

Strehler-Mildvan Model - 1960
plot.MortalityLaw

Plot Function for MortalityLaw
predict.MortalityLaw

Predict function for MortalityLaw
wittstein

Wittstein Mortality Law - 1883
print.ReadHMD

Print ReadHMD
print.ReadJMD

Print ReadJMD
makeham

Makeham Mortality Law - 1860
saveOutput

Save Output in the working directory
print.ReadAHMD

Print ReadCHMD
scale_x

Scaling method for x vector
vandermaen

Van der Maen Model - 1943
weibull

Weibull Mortality Law - 1939
vandermaen2

Van der Maen 2 Model - 1943
print.ReadCHMD

Print ReadCHMD
CANregions

Country codes
HMD_sample

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

HMD Indices
AUSregions

region codes
HP

Heligman-Pollard Mortality Law - 8 parameters - 1980
HP2

Heligman-Pollard 2 Mortality Law - 8 parameters
CHMD_sample

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

AIC function for MortalityLaw
AHMD_sample

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

Country codes
LawTable

Compute Life Tables from Parameters of a Mortality Law
LifeTable.check

Check LifeTable input
HP3

Heligman-Pollard 3 Mortality Law - 9 parameters