Download detailed mortality and population data for different countries and regions in a single object from the Human Mortality Database.
Usage
ReadHMD(
what,
countries = NULL,
interval = "1x1",
username,
password,
save = FALSE,
show = TRUE
)Arguments
- what
What type of data are you looking for? The following options might be available for some or all the countries and regions:
"births"– birth records (the 1-year product only; HMD does not publish births by 5-year age group or by multi-year periods);"Dx_lexis"– deaths by Lexis triangles;"Ex_lexis"– exposure-to-risk by Lexis triangles;"population"– population size;"Dx"– death counts;"Ex"– exposure-to-risk;"mx"– central death-rates;"LT_f"– period life tables for females;"LT_m"– period life tables for males;"LT_t"– period life tables both sexes combined;"e0"– period life expectancy at birth;"Exc"– cohort exposures;"mxc"– cohort death-rates;"LT_fc"– cohort life tables for females;"LT_mc"– cohort life tables for males;"LT_tc"– cohort life tables both sexes combined;"e0c"– cohort life expectancy at birth;
- countries
Specify the country data you want to download by adding the HMD country code/s. Options:
"AUS", "AUT", "BEL", "BGR", "BLR", "CAN", "CHL", "HRV", "HKG", "CHE", "CZE", "DEUTNP", "DEUTE", "DEUTW", "DNK", "ESP", "EST", "FIN", "FRATNP","FRACNP", "GRC", "HUN", "IRL", "ISL", "ISR", "ITA", "JPN", "KOR", "LTU", "LUX", "LVA", "NLD", "NOR", "NZL_NP", "NZL_MA","NZL_NM", "POL", "PRT", "RUS", "SVK", "SVN", "SWE", "TWN", "UKR", "GBR_NP","GBRTENW","GBRCENW","GBR_SCO", "GBR_NIR","USA". IfNULLdata for all the countries are downloaded at once;- interval
Datasets are given in various age and time formats based on which the records are aggregated. Interval options:
"1x1"– by age and year;"1x5"– by age and 5-year time interval;"1x10"– by age and 10-year time interval;"5x1"– by 5-year age group and year;"5x5"– by 5-year age group and 5-year time interval;"5x10"–by 5-year age group and 10-year time interval.
- username
Your HMD username. If you don't have one you can sign up for free on the Human Mortality Database website.
- password
Your HMD password.
- save
Do you want to save a copy of the dataset on your local machine? Logical. Default:
FALSE.- show
Choose whether to display a progress bar. Logical. Default:
TRUE.
Value
A ReadHMD object that contains:
- input
List with the input values (except the password).
- data
Data downloaded from HMD.
- download.date
Time stamp.
- years
Numerical vector with the years covered in the data.
- ages
Numerical vector with ages covered in the data.
Details
The Human Mortality Database is the reference source of detailed national
mortality and population data; see the project's own pages for its history
and research teams. A free account (and acceptance of the user agreement)
is required, and a dataset is only as detailed as the country publishes:
not every what exists for every country.
The login is performed once per call and reused for every country, so a
long countries vector costs one authentication. The password is
never stored in the returned object; input carries everything else,
for reproducibility.
Examples
if (FALSE) { # \dontrun{
# Download demographic data for 3 countries in 1x1 format
age_int <- 1 # age interval: 1,5
year_int <- 1 # year interval: 1,5,10
interval <- paste0(age_int, "x", year_int) # --> 1x1
# And the 3 countries: Sweden Denmark and USA. We have to use the HMD codes
cntr <- c('SWE', 'DNK', 'USA')
# Download death counts. We don't want to export data outside R.
HMD_Dx <- ReadHMD(what = "Dx",
countries = cntr,
interval = interval,
username = "user@email.com",
password = "password",
save = FALSE)
HMD_Dx
# Download life tables for female population and export data.
LTF <- ReadHMD(what = "LT_f",
countries = cntr,
interval = interval,
username = "user@email.com",
password = "password",
save = TRUE)
LTF
} # }