Last active
July 19, 2022 15:53
-
-
Save ikashnitsky/800e46910d07942093086b6b148d1d05 to your computer and use it in GitHub Desktop.
c19 IFR vs normal mortality – https://twitter.com/ikashnitsky/status/1483047960791457794
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#=============================================================================== | |
# 2022-01-17 -- twitter | |
# c19 IFR vs normal mortality | |
# Ilya Kashnitsky, ilya.kashnitsky@gmail.com, @ikashnitsky | |
#=============================================================================== | |
library(tidyverse) | |
library(magrittr) | |
library(hrbrthemes) | |
library(reticulate) | |
options(scipen = 999) | |
# load the ifr data collected by @zorinaq | |
# https://twitter.com/zorinaq/status/1330631088935370753 | |
# https://github.com/mbevand/covid19-age-stratified-ifr/blob/master/covid_vs_flu.py | |
# I copied the lines taht create IFR data object in a separate gist file | |
source_python("https://gist.githubusercontent.com/ikashnitsky/800e46910d07942093086b6b148d1d05/raw/18b1de1a47d1d0965124376f282b8652362effb1/zorinaq.py") | |
# simplify this list | |
foo <- ifrs_covid %>% unlist() | |
avg_vec <- function(x) {x %>% as.numeric %>% mean} | |
# turn into a data frame | |
ifr <- tibble( | |
name = foo %>% str_remove_all("[^\\p{L}']+") %>% na_if(""), | |
age = names(foo), | |
values = as.numeric(foo) | |
) %>% | |
fill(name, .direction = "down") %>% | |
drop_na() %>% | |
# calculate central age | |
mutate( | |
central_age = age %>% str_extract_all("[:alnum:]+") %>% | |
map(as.numeric) %>% map(mean) %>% unlist() | |
) | |
# !!! The code below assumes that one has full HMD downloaded and unpacked locally. To get a copy of it go to | |
# https://www.mortality.org/cgi-bin/hmd/hmd_download.php | |
# and choose "All statistics for HMD", currently 160326 Kb | |
# Ilya: my local copy was downloaded on 2021-02-02 | |
# functions to read local HMD directories | |
devtools::source_gist("0f93062f2b67eeac69949554027fa84f") | |
# the local HMD path (Ilya) | |
hmdpath <- fs::as_fs_path("~/data/hmd/") | |
# life tables | |
lt1x1 <- bind_rows( | |
b = path(hmdpath, "lt_both", "bltper_1x1") %>% fread_hmd_dir(), | |
f = path(hmdpath, "lt_female", "fltper_1x1") %>% fread_hmd_dir(), | |
m = path(hmdpath, "lt_male", "mltper_1x1") %>% fread_hmd_dir(), | |
.id = "sex" | |
) | |
lt1x1 %>% | |
group_by(country) %>% | |
filter(year == last(year)) %>% | |
ungroup() %>% | |
filter(sex == "b") %>% | |
ggplot()+ | |
stat_smooth( | |
aes(age, qx * 100, group = country), color = "#ffcdd277", | |
se = F, method = "loess", span = .2 | |
)+ | |
scale_y_continuous( | |
trans = "log10", | |
breaks = 10^(-3:2), | |
labels = c(".001", ".01", ".1", "1", "10", "100") | |
)+ | |
scale_x_continuous(breaks = seq(0, 110, 10))+ | |
geom_point(data = ifr, aes(central_age, values), color = "#df536b")+ | |
geom_smooth(data = ifr, aes(central_age, values), color = "#df536b", se = F)+ | |
theme_minimal(base_family = font_rc)+ | |
theme( | |
line = element_line(lineend = "round"), | |
panel.grid.minor = element_blank(), | |
plot.title = element_text(family = "Roboto Slab", face = 2) | |
)+ | |
labs( | |
title = "COVID-19 IFR vs baseline yearly mortality", | |
caption = "Data @HMDatabase; IFR collected by @zorinaq; design @ikashnitsky", | |
y = "Death probability, %", x = "Age" | |
)+ | |
annotate( | |
"text", label = c("Countries of HMD\n(last available year)", "COVID-19\nInfection Fatality Ratios"), | |
x = c(5, 45), y = c(7, .007), hjust = 0, vjust = 1, | |
family = "Roboto Slab", lineheight = .9, color = c("#ffcdd2", "#df536b") | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Age-stratified IFR estimates for COVID-19 | |
ifrs_covid = [ | |
# Calculated from Spanish ENE-COVID study | |
# (see calc_ifr.py) | |
('ENE-COVID', { | |
(0,9): 0.003, | |
(10,19): 0.004, | |
(20,29): 0.015, | |
(30,39): 0.030, | |
(40,49): 0.064, | |
(50,59): 0.213, | |
(60,69): 0.718, | |
(70,79): 2.384, | |
(80,89): 8.466, | |
(90,99): 12.497, | |
}), | |
# US CDC estimate as of 19 Mar 2021 | |
# https://www.cdc.gov/coronavirus/2019-ncov/hcp/planning-scenarios.html | |
# (table 1) | |
('US CDC', { | |
(0,17): 0.002, | |
(18,49): 0.05, | |
(50,64): 0.6, | |
(65,99): 9.0, | |
}), | |
# Verity et al. | |
# https://www.thelancet.com/journals/laninf/article/PIIS1473-3099(20)30243-7/fulltext | |
# (table 1) | |
('Verity', { | |
(0,9): 0.00161, | |
(10,19): 0.00695, | |
(20,29): 0.0309, | |
(30,39): 0.0844, | |
(40,49): 0.161, | |
(50,59): 0.595, | |
(60,69): 1.93, | |
(70,79): 4.28, | |
(80,99): 7.80, | |
}), | |
# Levin et al. | |
# https://link.springer.com/article/10.1007/s10654-020-00698-1 | |
# (table 3) | |
('Levin', { | |
(0,34): 0.004, | |
(35,44): 0.068, | |
(45,54): 0.23, | |
(55,64): 0.75, | |
(65,74): 2.5, | |
(75,84): 8.5, | |
(85,99): 28.3, | |
}), | |
# Salje et al.: Estimating the burden of SARS-CoV-2 in France | |
# https://science.sciencemag.org/content/369/6500/208 | |
# Supplementary Materials: | |
# https://science.sciencemag.org/content/sci/suppl/2020/05/12/science.abc3517.DC1/abc3517_Salje_SM_rev2.pdf | |
# (table S2) | |
('Salje', { | |
(0,19): 0.001, | |
(20,29): 0.005, | |
(30,39): 0.02, | |
(40,49): 0.05, | |
(50,59): 0.2, | |
(60,69): 0.7, | |
(70,79): 1.9, | |
(80,99): 8.3, | |
}), | |
# Perez-Saez et al. | |
# https://www.thelancet.com/journals/laninf/article/PIIS1473-3099(20)30584-3/fulltext | |
('Perez-Saez', { | |
(5,9): 0.0016, | |
(10,19): 0.00032, | |
(20,49): 0.0092, | |
(50,64): 0.14, | |
(65,99): 5.6, | |
}), | |
# Picon et al. | |
# https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7493765/ | |
# (table 2) | |
('Picon', { | |
(20,39): 0.08, | |
(40,59): 0.24, | |
(60,99): 4.63, | |
}), | |
# Poletti et al. | |
# https://www.eurosurveillance.org/content/10.2807/1560-7917.ES.2020.25.31.2001383 | |
# (table 1, column "Any time") | |
('Poletti', { | |
(0,19): 0, | |
(20,49): 0, | |
(50,59): 0.46, | |
(60,69): 1.42, | |
(70,79): 6.87, | |
(80,99): 18.35, | |
}), | |
# Gudbjartsson et al.: Humoral Immune Response to SARS-CoV-2 in Iceland | |
# https://www.nejm.org/doi/full/10.1056/NEJMoa2026116 | |
# Supplementary Appendix 1 | |
# https://www.nejm.org/doi/suppl/10.1056/NEJMoa2026116/suppl_file/nejmoa2026116_appendix_1.pdf | |
# (table S7) | |
('Gudbjartsson', { | |
(0,70): 0.1, | |
(71,80): 2.4, | |
(81,99): 11.2, | |
}), | |
# Public Health Agency of Sweden | |
# https://www.folkhalsomyndigheten.se/contentassets/53c0dc391be54f5d959ead9131edb771/infection-fatality-rate-covid-19-stockholm-technical-report.pdf | |
# (table B.1) | |
('PHAS', { | |
(0,49): 0.01, | |
(50,59): 0.27, | |
(60,69): 0.45, | |
(70,79): 1.92, | |
(80,89): 7.20, | |
(90,99): 16.21, | |
}), | |
# O’Driscoll et al.: Age-specific mortality and immunity patterns of SARS-CoV-2 | |
# https://www.nature.com/articles/s41586-020-2918-0 | |
# Supplementary information | |
# https://static-content.springer.com/esm/art%3A10.1038%2Fs41586-020-2918-0/MediaObjects/41586_2020_2918_MOESM1_ESM.pdf | |
# (table S3) | |
('O’Driscoll', { | |
(0,4): 0.003, | |
(5,9): 0.001, | |
(10,14): 0.001, | |
(15,19): 0.003, | |
(20,24): 0.006, | |
(25,29): 0.013, | |
(30,34): 0.024, | |
(35,39): 0.040, | |
(40,44): 0.075, | |
(45,49): 0.121, | |
(50,54): 0.207, | |
(55,59): 0.323, | |
(60,64): 0.456, | |
(65,69): 1.075, | |
(70,74): 1.674, | |
(75,79): 3.203, | |
(80,99): 8.292, | |
}), | |
# Ward et al.: Antibody prevalence for SARS-CoV-2 in England following first peak of the pandemic: REACT2 study in 100,000 adults | |
# https://www.nature.com/articles/s41467-021-21237-w | |
# (table 2) | |
('REACT2', { | |
(15,44): 0.03, | |
(45,64): 0.52, | |
(65,74): 3.13, | |
(75,99): 11.64, | |
}), | |
# Yang et al.: Estimating the infection fatality risk of COVID-19 in New York City during the spring 2020 pandemic wave | |
# https://www.medrxiv.org/content/10.1101/2020.06.27.20141689v2 | |
# (table 1) | |
('Yang', { | |
(0,24): 0.0097, | |
(25,44): 0.12, | |
(45,64): 0.94, | |
(65,74): 4.87, | |
(75,99): 14.17, | |
}), | |
# Molenberghs et al.: Belgian Covid-19 Mortality, Excess Deaths, Number of Deaths per Million, and Infection Fatality Rates | |
# https://www.medrxiv.org/content/10.1101/2020.06.20.20136234v1 | |
# (table 6) | |
('Molenberghs', { | |
(0,24): 0.0005, | |
(25,44): 0.017, | |
(45,64): 0.21, | |
(65,74): 2.24, | |
(75,84): 4.29, | |
(85,99): 11.77, | |
}), | |
# Brazeau et al. | |
# https://www.imperial.ac.uk/mrc-global-infectious-disease-analysis/covid-19/report-34-ifr/ | |
# (table 2, column "IFR (%) with Seroreversion") | |
('Brazeau', { | |
(0,4): 0.00, | |
(5,9): 0.01, | |
(10,14): 0.01, | |
(15,19): 0.02, | |
(20,24): 0.02, | |
(25,29): 0.04, | |
(30,34): 0.06, | |
(35,39): 0.09, | |
(40,44): 0.15, | |
(45,49): 0.23, | |
(50,54): 0.36, | |
(55,59): 0.57, | |
(60,64): 0.89, | |
(65,69): 1.39, | |
(70,74): 2.17, | |
(75,79): 3.39, | |
(80,84): 5.30, | |
(85,89): 8.28, | |
(90,99): 16.19, | |
}), | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment