Skip to contents

Apply 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() or sim_summarise_linelist()

A dataframe containing the following 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 t and returns a probability of ascertainment, e.g. ~ stats::rbeta(.x, 20, 80) or ~ rbeta2(.x,prob=<probability>,kappa=<dispersion>). or cfg_weekly_proportion_rng()

seed

a RNG seed

Value

a dataframe with original column, and count column modified to include ascertainment bias.

Examples

tibble::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))
#> # A tibble: 10 × 5
#> # Groups:   statistic [1]
#>    statistic time       count original ascertainment
#>    <chr>     <time_prd> <int>    <int>         <dbl>
#>  1 incidence  1            10      100           0.1
#>  2 incidence  2            11      100           0.1
#>  3 incidence  3            10      100           0.1
#>  4 incidence  4             8      100           0.1
#>  5 incidence  5            12      100           0.1
#>  6 incidence  6            94      100           0.9
#>  7 incidence  7            88      100           0.9
#>  8 incidence  8            88      100           0.9
#>  9 incidence  9            90      100           0.9
#> 10 incidence 10            91      100           0.9