Skip to contents

Move forward one generation in the branching process

Usage

outbreak_step(case_data, offspring, delays, event_probs, interventions)

Arguments

case_data

a data.table: cases in outbreak so far; initially generated by outbreak_setup()

offspring

a list with class <ringbp_offspring_opts>: the offspring distribution functions for the ringbp model, returned by offspring_opts(). Contains three elements: community, isolated, and asymptomatic

delays

a list with class <ringbp_delay_opts>: the delay distribution functions for the ringbp model, returned by delay_opts(). Contains two elements: incubation_period and onset_to_isolation

event_probs

a list with class <ringbp_event_prob_opts>: the event probabilities for the ringbp model, returned by event_prob_opts(). Contains three elements: asymptomatic, presymptomatic_transmission and symptomatic_ascertained

interventions

a list with class <ringbp_intervention_opts>: the intervention settings for the ringbp model, returned by intervention_opts(). Contains one element: quarantine

Value

A list with three elements:

  1. $cases: a data.table with case data

  2. $effective_r0: a numeric with the effective reproduction number

  3. $cases_in_gen: a numeric with the number of new cases in that generation

Examples

offspring <- offspring_opts(
  community = \(n) rnbinom(n = n, mu = 2.5, size = 0.16),
  isolated = \(n) rnbinom(n = n, mu = 0, size = 1),
  asymptomatic = \(n) rnbinom(n = n, mu = 1.25, size = 0.16)
)
delays <- delay_opts(
  incubation_period = \(n) rweibull(n = n, shape = 2.32, scale = 6.49),
  onset_to_isolation = \(n) rweibull(n = n, shape = 1.65, scale = 4.28)
)
event_probs <- event_prob_opts(
  asymptomatic = 0,
  presymptomatic_transmission = 0.15,
  symptomatic_ascertained = 0
)
interventions <- intervention_opts(quarantine = FALSE)

# generate initial cases
case_data <- outbreak_setup(
  initial_cases = 5,
  delays = delays,
  event_probs = event_probs
)
case_data
#> Index: <asymptomatic>
#>    exposure asymptomatic caseid infector missed     onset new_cases
#>       <num>       <lgcl>  <int>    <num> <lgcl>     <num>     <int>
#> 1:        0        FALSE      1        0   TRUE  9.068614        NA
#> 2:        0        FALSE      2        0   TRUE  7.134836        NA
#> 3:        0        FALSE      3        0   TRUE  7.409368        NA
#> 4:        0        FALSE      4        0   TRUE  3.831935        NA
#> 5:        0        FALSE      5        0   TRUE 12.451065        NA
#>    isolated_time sampled
#>            <num>  <lgcl>
#> 1:     17.360308   FALSE
#> 2:     10.430046   FALSE
#> 3:      9.035117   FALSE
#> 4:     15.099694   FALSE
#> 5:     16.355962   FALSE
# generate next generation of cases
out <- outbreak_step(
  case_data = case_data,
  offspring = offspring,
  delays = delays,
  event_probs = event_probs,
  interventions = interventions
)
case_data <- out[[1]]
case_data
#>      exposure asymptomatic caseid infector missed     onset new_cases
#>         <num>       <lgcl>  <int>    <num> <lgcl>     <num>     <int>
#>  1:  0.000000        FALSE      1        0   TRUE  9.068614         6
#>  2:  0.000000        FALSE      2        0   TRUE  7.134836         0
#>  3:  0.000000        FALSE      3        0   TRUE  7.409368         0
#>  4:  0.000000        FALSE      4        0   TRUE  3.831935         0
#>  5:  0.000000        FALSE      5        0   TRUE 12.451065        14
#>  6: 10.684477        FALSE      6        1   TRUE 18.416225        NA
#>  7: 11.385832        FALSE      7        1   TRUE 15.003998        NA
#>  8: 10.176903        FALSE      8        1   TRUE 15.028419        NA
#>  9:  9.312653        FALSE      9        1   TRUE 14.598350        NA
#> 10: 10.239543        FALSE     10        1   TRUE 14.286632        NA
#> 11:  9.170390        FALSE     11        1   TRUE 18.738731        NA
#> 12: 12.990119        FALSE     12        5   TRUE 19.830682        NA
#> 13: 14.255198        FALSE     13        5   TRUE 18.637028        NA
#> 14: 12.961801        FALSE     14        5   TRUE 17.212470        NA
#> 15: 12.874304        FALSE     15        5   TRUE 15.957546        NA
#> 16: 13.131607        FALSE     16        5   TRUE 16.887905        NA
#> 17: 12.940163        FALSE     17        5   TRUE 20.887224        NA
#> 18: 14.945229        FALSE     18        5   TRUE 22.751088        NA
#> 19: 16.080431        FALSE     19        5   TRUE 21.357583        NA
#> 20: 16.174508        FALSE     20        5   TRUE 20.972771        NA
#> 21: 11.815477        FALSE     21        5   TRUE 16.492315        NA
#> 22: 13.589812        FALSE     22        5   TRUE 17.914329        NA
#> 23: 13.819688        FALSE     23        5   TRUE 23.393422        NA
#> 24: 13.327341        FALSE     24        5   TRUE 16.501959        NA
#> 25: 13.200103        FALSE     25        5   TRUE 18.777442        NA
#>      exposure asymptomatic caseid infector missed     onset new_cases
#>     isolated_time sampled
#>             <num>  <lgcl>
#>  1:     17.360308    TRUE
#>  2:     10.430046    TRUE
#>  3:      9.035117    TRUE
#>  4:     15.099694    TRUE
#>  5:     16.355962    TRUE
#>  6:     28.608812   FALSE
#>  7:     15.177175   FALSE
#>  8:     21.919639   FALSE
#>  9:     16.201172   FALSE
#> 10:     17.935170   FALSE
#> 11:     25.011139   FALSE
#> 12:     25.008372   FALSE
#> 13:     23.594261   FALSE
#> 14:     22.801945   FALSE
#> 15:     26.596407   FALSE
#> 16:     23.809008   FALSE
#> 17:     27.978250   FALSE
#> 18:     31.509749   FALSE
#> 19:     24.464735   FALSE
#> 20:     23.710582   FALSE
#> 21:     21.213359   FALSE
#> 22:     22.097602   FALSE
#> 23:     25.188005   FALSE
#> 24:     22.806482   FALSE
#> 25:     19.811604   FALSE
#>     isolated_time sampled