library(data.table)
f_param <- function(age_in_years) {
(10^(-3.27 + 0.0524 * age_in_years))/100
}
model_partition <- c(0, 5, 20, 65, 101)
density_dt <- data.table(
from = 0:101, weight = c(rep(1, 66), exp(-0.075 * 1:35), 0)
)
alembic_dt <- alembic(
f_param, density_dt, model_partition, seq(0, 101, by = 1L)
)
# for simplicity, assume a uniform force-of-infection across ages =>
# infections proportion to population density.
model_outcomes_dt <- density_dt[from != max(from), .(value = sum(f_param(from) * weight)),
by = .(model_from = model_partition[findInterval(from, model_partition)])
]
ds_dt <- distill_summary(alembic_dt, model_outcomes_dt)
Run the code above in your browser using DataLab