
Apply a ascertainment bias to the observed case counts.
Source:R/simulation-utils.R
sim_apply_ascertainment.RdApply a ascertainment bias to the observed case counts.
Usage
sim_apply_ascertainment(df = i_sim_count_data, fn_asc = ~1, seed = Sys.time())Arguments
- df
a count dataframe from e.g.
sim_poisson_model()orsim_summarise_linelist()- a dataframe with columns:statistic (character) - An identifier for the statistic, whether that be infections, admissions, deaths
count (positive_integer) - Positive case counts associated with the specified time frame
time (ggoutbreak::time_period + group_unique) - A (usually complete) set of singular observations per unit time as a `time_period`
Minimally grouped by: statistic (and other groupings allowed).
- fn_asc
a function that takes a single input vector
tand returns a probability of ascertainment, e.g.~ stats::rbeta(.x, 20, 80)or~ rbeta2(.x,prob=<probability>,kappa=<dispersion>). orcfg_weekly_proportion_rng()- seed
a RNG seed
Examples
with_defaults("2025-01-01" ,"1 day", {
dplyr::tibble(
statistic = "incidence",
time=as.time_period(1:10,"1 day"),
count=rep(100,10)
) %>%
dplyr::group_by(statistic) %>%
sim_apply_ascertainment(~ ifelse(.x<=5,0.1,0.9))
})