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_traced

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_traced = 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 traced    onset new_cases
#>       <num>       <lgcl>  <int>    <num> <lgcl>    <num>     <int>
#> 1:        0        FALSE      1        0  FALSE 2.581700        NA
#> 2:        0        FALSE      2        0  FALSE 4.811051        NA
#> 3:        0        FALSE      3        0  FALSE 7.008587        NA
#> 4:        0        FALSE      4        0  FALSE 9.262499        NA
#> 5:        0        FALSE      5        0  FALSE 5.827982        NA
#>    isolated_time sampled
#>            <num>  <lgcl>
#> 1:      3.641819   FALSE
#> 2:     11.661816   FALSE
#> 3:     11.898353   FALSE
#> 4:     14.418862   FALSE
#> 5:      7.868309   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 traced     onset new_cases
#>         <num>       <lgcl>  <int>    <num> <lgcl>     <num>     <int>
#>  1:  0.000000        FALSE      1        0  FALSE  2.581700         0
#>  2:  0.000000        FALSE      2        0  FALSE  4.811051         6
#>  3:  0.000000        FALSE      3        0  FALSE  7.008587         0
#>  4:  0.000000        FALSE      4        0  FALSE  9.262499         3
#>  5:  0.000000        FALSE      5        0  FALSE  5.827982         0
#>  6:  8.778479        FALSE      6        2  FALSE 14.348074        NA
#>  7:  7.955102        FALSE      7        2  FALSE 11.189982        NA
#>  8:  8.702365        FALSE      8        2  FALSE 13.061108        NA
#>  9:  7.119254        FALSE      9        2  FALSE  8.336304        NA
#> 10:  5.532936        FALSE     10        2  FALSE 12.868323        NA
#> 11:  5.232672        FALSE     11        2  FALSE  7.312398        NA
#> 12:  9.630210        FALSE     12        4  FALSE 16.542692        NA
#> 13: 11.769312        FALSE     13        4  FALSE 19.913290        NA
#> 14: 10.156739        FALSE     14        4  FALSE 14.509729        NA
#>     isolated_time sampled
#>             <num>  <lgcl>
#>  1:      3.641819    TRUE
#>  2:     11.661816    TRUE
#>  3:     11.898353    TRUE
#>  4:     14.418862    TRUE
#>  5:      7.868309    TRUE
#>  6:     16.319629   FALSE
#>  7:     12.835367   FALSE
#>  8:     15.083510   FALSE
#>  9:     13.040281   FALSE
#> 10:     18.433117   FALSE
#> 11:     13.036644   FALSE
#> 12:     21.622686   FALSE
#> 13:     23.716574   FALSE
#> 14:     17.977972   FALSE