# COVID IFR from Levin et al 2020 https://doi.org/10.1007/s10654-020-00698-1
f_param <- function(age_in_years) {
(10^(-3.27 + 0.0524 * age_in_years))/100
}
densities <- data.frame(
from = 0:101,
weight = c(rep(1, 66), exp(-0.075 * 1:35), 0)
)
model_partition <- c(0, 5, 20, 65, 101)
ps_dt <- parameter_summary(f_param, densities, model_partition)
ps_dt
ggplot(ps_dt) + aes(x, y = value, color = method) +
geom_line(data = \(dt) subset(dt, method == "f_val")) +
geom_step(data = \(dt) subset(dt, method != "f_val")) +
theme_bw() + theme(
legend.position = "inside", legend.position.inside = c(0.05, 0.95),
legend.justification = c(0, 1)
) + scale_color_discrete(
"Method", labels = c(
f_val = "f(x)", f_mid = "f(mid(x))", f_mean = "f(E[x])",
mean_f = "discrete E[f(x)]", wm_f = "integrated E[f(x)]"
)
) +
scale_x_continuous("Age", breaks = seq(0, 100, by = 10)) +
scale_y_log10("IFR", breaks = 10^c(-6, -4, -2, 0), limits = 10^c(-6, 0))
Run the code above in your browser using DataLab