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 4 elements: incubation_period, onset_to_isolation, latent_period and onset_to_self_isolation

event_probs

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

interventions

a list with class <ringbp_intervention_opts>: the intervention settings for the ringbp model, returned by intervention_opts(). Contains 2 elements: quarantine and test_sensitivity

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

Details

Each new case is assigned an isolation time (isolated_time) as the earliest of up to three pathways; a case to which no pathway applies is never isolated (isolated_time is Inf):

  • Self-isolation: a symptomatic case self-isolates with probability symptomatic_self_isolate (from event_prob_opts()), entering isolation an onset_to_self_isolation delay (from delay_opts()) after symptom onset. Self-isolating cases are not tested.

  • Testing: a symptomatic case that does not self-isolate is tested and returns a positive result with probability test_sensitivity (from intervention_opts()), entering isolation an onset_to_isolation delay after symptom onset. A false-negative result does not isolate the case via this pathway.

  • Tracing: a case whose infector is symptomatic is traced with probability symptomatic_traced (from event_prob_opts()). When quarantine is active (from intervention_opts()) tracing is exposure-based: a traced case is isolated when its infector is isolated, regardless of its own symptom status. Without quarantine, only a traced symptomatic case is isolated, and no earlier than its own symptom onset.

Self-isolation and testing are symptom-based, so asymptomatic cases are isolated only via the tracing pathway, and only when quarantine is active.

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,
  interventions = interventions
)
case_data
#> Index: <self_isolate__asymptomatic>
#>    exposure asymptomatic caseid infector traced    onset new_cases self_isolate
#>       <num>       <lgcl>  <int>    <num> <lgcl>    <num>     <int>       <lgcl>
#> 1:        0        FALSE      1        0  FALSE 1.173089        NA        FALSE
#> 2:        0        FALSE      2        0  FALSE 8.745576        NA        FALSE
#> 3:        0        FALSE      3        0  FALSE 4.773823        NA        FALSE
#> 4:        0        FALSE      4        0  FALSE 7.845297        NA        FALSE
#> 5:        0        FALSE      5        0  FALSE 2.786544        NA        FALSE
#>    isolated_time sampled
#>            <num>  <lgcl>
#> 1:      2.059485   FALSE
#> 2:     12.840092   FALSE
#> 3:     11.844717   FALSE
#> 4:      8.844933   FALSE
#> 5:      6.115403   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  1.173089         0
#> 2:  0.000000        FALSE      2        0  FALSE  8.745576         1
#> 3:  0.000000        FALSE      3        0  FALSE  4.773823         1
#> 4:  0.000000        FALSE      4        0  FALSE  7.845297         0
#> 5:  0.000000        FALSE      5        0  FALSE  2.786544         0
#> 6: 11.076900        FALSE      6        2  FALSE 19.220878        NA
#> 7:  6.707449        FALSE      7        3  FALSE 11.060438        NA
#>    self_isolate isolated_time sampled
#>          <lgcl>         <num>  <lgcl>
#> 1:        FALSE      2.059485    TRUE
#> 2:        FALSE     12.840092    TRUE
#> 3:        FALSE     11.844717    TRUE
#> 4:        FALSE      8.844933    TRUE
#> 5:        FALSE      6.115403    TRUE
#> 6:        FALSE     22.211813   FALSE
#> 7:        FALSE     18.344412   FALSE