Relative age-standardised mortality

Analysis from the Office for National Statistics compares European nations.

Anthony B. Masters

--

In my co-written book Covid by Numbers, a graph shows relative age-standardised mortality. The graph in the book has a production error, where the UK lines do not have correct alignment. The original version, made in R, looks like:

(Image: Covid By Numbers)

What are relative age-standardised mortality rates? To calculate age-standardised mortality, we need to find mortality rates within age groups. Next, analysts calculate the weighted average of these age-specific rates. The weights come from a standard population, here: the 2013 European Standard population. This index is then

The Office for National Statistics updated their analysis. Now, we can update this graph. In the original version, I uploaded a spreadsheet containing the mortality statistics. This time, I want to draw straight from the online file. That helps make the code more reproducible.

To achieve that goal, I use the curl package:

temp <- tempfile()
temp <- curl_download(url = ons_rasmr_url, destfile = temp,
quiet = TRUE, mode = "wb")
ons_rasmr_tbl <- read_excel(temp,
sheet = ons_rasmr_sheet,
range = ons_rasmr_range)

The main table has columns, writing weeks in the format ‘YYYYWXX’. For instance, the first week of 2020 would be 2020W01.

There is a secondary table containing week dates and numbers. Using a formatting function, I create a new column with those column names:

ons_week_sheet <- "Week number dates "
ons_week_range <- "A8:D357"
ons_week_tbl <- read_excel(temp,
sheet = ons_week_sheet,
range = ons_week_range)

ons_week_number_df <- ons_week_tbl %>%
janitor::clean_names() %>%
dplyr::mutate(
week_number = paste0(year, "W", formatC(week, flag = 0, width = 2)),
start_date = as_date(start_date),
end_date = as_date(end_date)) %>%
dplyr::rename(
week_start_date = start_date,
week_end_date = end_date)

The main table has missing values, with ‘z’. That means the data was not available. In R, drawing that table would mean the extant values get…

--

--

Anthony B. Masters

This blog looks at the use of statistics in Britain and beyond. It is written by RSS Statistical Ambassador and Chartered Statistician @anthonybmasters.