get_mortality_data: Get the multipopulation mortality dataset

View source: R/get_mortality_data.R

get_mortality_dataR Documentation

Get the multipopulation mortality dataset

Description

This function returns the country-specific and combined death counts and exposures for a selection of countries from the Human Mortality Database (HMD) and/or Eurostat and for both males and females.

Usage

get_mortality_data(
  xv,
  yv,
  yv_spec,
  countries,
  country_spec,
  username,
  password
)

Arguments

xv

Numeric. The vector of ages.

yv

The vector of years.

yv_spec

The vector of years for the country of interest.

countries

The vector of countries.

country_spec

The country of interest.

username

The username of your HMD account.

password

The password of your HMD acccount.

Details

This function downloads and/or calculates the death counts and exposures for an age range xv, a time range yv and for a specified set of countries countries. The main data source is HMD. The second one is Eurostat for the years for which there is no data available at the HMD. From the HMD database this functions downloads the tables Deaths and Exposure to risk in 1x1 format. In the case of Germany (DE), we consider West-Germany instead of whole Germany for the period before the German unification (...-1989). At the Eurostat database we download the databases demo_mager (period deaths), demo_magec (cohort deaths) and demo_pjan (population size). Period exposures are calculated from these datasets according to the HMD protocol.

The argument countries should contain the user code labels of your countries of interest. The available countries and their corresponding user codes are given in the dataset country_codes, provided in this package.

Further, you have to register on HMD and provide the function with your username and password such that the function can automatically download from HMD.

Remark that the year ranges yv and yv_spec should not be the same. Typically a longer year range for yv is chosen and yv_spec consists of some more recent years. When we download data for your country of interest (country_spec), we consider the year range min(yv,yv_spec):tail(yv_spec,1) since the older data is also used for estimating the common mortality trend.

Value

A list containing:

  • $M (male data), $F (female data)

  • $UNI (individual mortality data: $BE (Belgium), $NL (Netherlands), $AT (Austria), ...), $ALL (combined data)

  • $dtx (deaths), $etx (exposures), $wa (weights).

Examples

## Not run: 
xv <- 0:90
yv <- 1970:2015
yv_spec <- 1985:2018
countries <- c("BE", "IT", "UK", "DE")
country_spec <- "BE"
username <- ""
password <- ""
data <- get_mortality_data(xv, yv, yv_spec, countries, country_spec, username, password)

## End(Not run)


RobbenJ/MultiMoMo documentation built on June 28, 2022, 9:29 p.m.