Move forward one generation in the branching process

outbreak_step(
  case_data,
  r0_community,
  r0_isolated,
  r0_asymptomatic,
  disp_community,
  disp_isolated,
  disp_asymptomatic,
  incubation_period,
  alpha,
  onset_to_isolation,
  prop_ascertain,
  prop_asymptomatic,
  quarantine = FALSE
)

Arguments

case_data

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

r0_community

a positive numeric scalar: reproduction number for non-isolated cases (must be >0)

r0_isolated

a positive numeric scalar: reproduction number for isolated cases (must be >0)

r0_asymptomatic

a positive numeric scalar: reproduction number for sub-clinical non-isolated cases (must be >0)

disp_community

a positive numeric scalar: dispersion parameter for non-isolated cases (must be >0)

disp_isolated

a positive numeric scalar: dispersion parameter for isolated cases (must be >0)

disp_asymptomatic

a positive numeric scalar: dispersion parameter for sub-clincial non-isolated cases (must be >0)

incubation_period

a function: a random number generating function that samples from incubation period distribution, the function accepts a single integer argument specifying the number of times to sample the incubation period (i.e. length of the function output).

alpha

a numeric scalar: skew parameter of the skew-normal distribution

onset_to_isolation

a function: a random number generating function that accepts a single integer argument specifying the length of the function output.

prop_ascertain

a numeric scalar probability (between 0 and 1 inclusive): proportion of infectious contacts ascertained by contact tracing

prop_asymptomatic

a numeric scalar probability (between 0 and 1 inclusive): proportion of cases that are completely asymptomatic (subclinical)

quarantine

a logical scalar: whether quarantine is in effect, if TRUE then traced contacts are isolated before symptom onset; defaults to FALSE

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

Author

Joel Hellewell

Examples

# incubation period sampling function
incubation_period <- \(x) rweibull(n = x, shape = 2.32, scale = 6.49)
# delay distribution sampling function
onset_to_isolation <- \(x) rweibull(n = x, shape = 1.65, scale = 4.28)
# generate initial cases
case_data <- outbreak_setup(
  initial_cases = 5,
  incubation_period = incubation_period,
  onset_to_isolation = onset_to_isolation,
  prop_asymptomatic = 0
)
case_data
#> Index: <asymptomatic>
#>    exposure asymptomatic caseid infector isolated missed    onset new_cases
#>       <num>       <lgcl>  <int>    <num>   <lgcl> <lgcl>    <num>    <lgcl>
#> 1:        0        FALSE      1        0    FALSE   TRUE 9.022516        NA
#> 2:        0        FALSE      2        0    FALSE   TRUE 4.988084        NA
#> 3:        0        FALSE      3        0    FALSE   TRUE 4.362592        NA
#> 4:        0        FALSE      4        0    FALSE   TRUE 5.893255        NA
#> 5:        0        FALSE      5        0    FALSE   TRUE 7.811025        NA
#>    isolated_time
#>            <num>
#> 1:     11.726327
#> 2:      9.850911
#> 3:      5.461769
#> 4:     10.612659
#> 5:     12.159468
# generate next generation of cases
out <- outbreak_step(
  case_data = case_data,
  disp_isolated = 1,
  disp_community = 0.16,
  disp_asymptomatic = 0.16,
  r0_isolated = 0,
  r0_asymptomatic = 1.25,
  r0_community = 2.5,
  prop_asymptomatic = 0,
  incubation_period = incubation_period,
  onset_to_isolation = onset_to_isolation,
  prop_ascertain = 0,
  alpha = 1.95,
  quarantine = FALSE
)
case_data <- out[[1]]
case_data
#>     exposure asymptomatic caseid infector isolated missed     onset new_cases
#>        <num>       <lgcl>  <int>    <num>   <lgcl> <lgcl>     <num>     <num>
#>  1: 0.000000        FALSE      1        0     TRUE   TRUE  9.022516         0
#>  2: 0.000000        FALSE      2        0     TRUE   TRUE  4.988084         0
#>  3: 0.000000        FALSE      3        0     TRUE   TRUE  4.362592         2
#>  4: 0.000000        FALSE      4        0     TRUE   TRUE  5.893255         4
#>  5: 0.000000        FALSE      5        0     TRUE   TRUE  7.811025         1
#>  6: 4.475263        FALSE      6        3    FALSE   TRUE 11.148345        NA
#>  7: 7.582684        FALSE      7        4    FALSE   TRUE 11.802298        NA
#>  8: 8.019250        FALSE      8        4    FALSE   TRUE 12.798781        NA
#>  9: 7.044943        FALSE      9        4    FALSE   TRUE 12.839532        NA
#> 10: 6.963220        FALSE     10        4    FALSE   TRUE  9.133825        NA
#> 11: 9.139614        FALSE     11        5    FALSE   TRUE 11.520742        NA
#>     isolated_time
#>             <num>
#>  1:     11.726327
#>  2:      9.850911
#>  3:      5.461769
#>  4:     10.612659
#>  5:     12.159468
#>  6:     15.416323
#>  7:     19.084499
#>  8:     17.965948
#>  9:     15.075816
#> 10:     19.073315
#> 11:     18.784039