HMD2MH: Format data from the Human Mortality Database for use in the...

Description Usage Arguments Details Value References See Also


Format data from the Human Mortality Database for use in the MortHump package


HMD2MH(country, year, dim = "period", xtra = FALSE, sex, min = 0,
  max = NULL, username = NULL, password = NULL, path = NULL)



HMD population letter code


year (or birth cohort) for which the data is required


dimension (period or cohort)


if TRUE extrapolates non-extinct cohorts


sex for which the data is required ("females", "males" or "total")


age at which the data should be left-censored


age at which the data should be right-censored


personal HMD username for web access


personal HMD password for web access


path to the HMD folder for local access (containing the country folders)


Two methods are available to access the data, either online or locally. Web access is advised to guarantee the most recent data, but can be slow. For a fast access, download first the complete zipped data files (choose "All countries for the HMD"), and then indicate the path to the general folder. The data collection method will be adapted depending if you indicate a path or a username and a password.

If you choose cohort data, you have the option of either work with the observed data, or to extrapolate the non-extinct cohorts. In the latter case, a variant of the Lee-Carter model is used to extrapolate the period mortality rates, which are used to identify cohort rates in the diagonal of the Lexis matrix. This option uses a variant of the Lee-Carter model, namely the functional model proposed by Hyndman and Ullah (2007) and available in the demography package.

The list of available countries and period coverage can be found on the HMD website. This list is also accessible with the function getHMDcountries() from the HMDHFDplus package.

The max argument is designed to deal with either the presence of a mortality plateau among centenarians, which can be diffcult to capture with parametric models, or a high level of stochasticity at old ages due to a small number of survivors. It is recommended to keep the value of max above 80 or 90.


A data frame containing the following variables.


vector of ages.


vector of death counts.


vector of population exposures.


vector of death rates.


Human Mortality Database. University of California, Berkeley (USA), and Max Planck Institute for Demographic Research (Germany). Available at or

See Also

This function makes use of the functions readHMD and readHMDweb from the HMDHFDplus package.

Search within the MortHump package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.