Run a single instance of the branching process model

outbreak_model(
  initial_cases,
  r0_community,
  r0_isolated,
  r0_asymptomatic,
  disp_community,
  disp_isolated,
  disp_asymptomatic,
  incubation_period,
  prop_presymptomatic,
  onset_to_isolation,
  prop_ascertain,
  prop_asymptomatic,
  cap_max_days,
  cap_cases,
  quarantine = FALSE
)

Arguments

initial_cases

a nonnegative integer scalar: number of initial or starting cases which are all assumed to be missed.

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).

prop_presymptomatic

a numeric scalar probability (between 0 and 1 inclusive): proportion of transmission that occurs before symptom onset.

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)

cap_max_days

a positive integer scalar: stop the simulation when this many days is reached.

cap_cases

a positive integer scalar: number of cumulative cases at which the branching process (simulation) was terminated

quarantine

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

Value

data.table of cases by week, cumulative cases, and the effective reproduction number of the outbreak. data.table columns are:

  • $week: numeric

  • $weekly_cases: numeric

  • $cumulative: numeric

  • $effective_r0: numeric

  • $cases_per_gen: list

Author

Joel Hellewell

Examples

set.seed(1)
out <- outbreak_model(
  initial_cases = 1,
  prop_ascertain = 0.2,
  cap_max_days = 350,
  cap_cases = 4500,
  r0_isolated = 0.5,
  r0_community = 2.5,
  r0_asymptomatic = 2.5,
  disp_isolated = 1,
  disp_community = 0.16,
  disp_asymptomatic = 0.16,
  prop_presymptomatic = 0.5,
  onset_to_isolation = \(x) rweibull(n = x, shape = 1.65, scale = 4.28),
  incubation_period = \(x) rweibull(n = x, shape = 2.32, scale = 6.49),
  prop_asymptomatic = 0,
  quarantine = FALSE
)
out
#>      week weekly_cases cumulative effective_r0
#>     <num>        <num>      <num>        <num>
#>  1:     0            2          2     4.295861
#>  2:     1           47         49     4.295861
#>  3:     2          253        302     4.295861
#>  4:     3          865       1167     4.295861
#>  5:     4         1550       2717     4.295861
#>  6:     5         1857       4574     4.295861
#>  7:     6         1336       5910     4.295861
#>  8:     7          412       6322     4.295861
#>  9:     8           49       6371     4.295861
#> 10:     9            1       6372     4.295861
#> 11:    10            0       6372     4.295861
#> 12:    11            0       6372     4.295861
#> 13:    12            0       6372     4.295861
#> 14:    13            0       6372     4.295861
#> 15:    14            0       6372     4.295861
#> 16:    15            0       6372     4.295861
#> 17:    16            0       6372     4.295861
#> 18:    17            0       6372     4.295861
#> 19:    18            0       6372     4.295861
#> 20:    19            0       6372     4.295861
#> 21:    20            0       6372     4.295861
#> 22:    21            0       6372     4.295861
#> 23:    22            0       6372     4.295861
#> 24:    23            0       6372     4.295861
#> 25:    24            0       6372     4.295861
#> 26:    25            0       6372     4.295861
#> 27:    26            0       6372     4.295861
#> 28:    27            0       6372     4.295861
#> 29:    28            0       6372     4.295861
#> 30:    29            0       6372     4.295861
#> 31:    30            0       6372     4.295861
#> 32:    31            0       6372     4.295861
#> 33:    32            0       6372     4.295861
#> 34:    33            0       6372     4.295861
#> 35:    34            0       6372     4.295861
#> 36:    35            0       6372     4.295861
#> 37:    36            0       6372     4.295861
#> 38:    37            0       6372     4.295861
#> 39:    38            0       6372     4.295861
#> 40:    39            0       6372     4.295861
#> 41:    40            0       6372     4.295861
#> 42:    41            0       6372     4.295861
#> 43:    42            0       6372     4.295861
#> 44:    43            0       6372     4.295861
#> 45:    44            0       6372     4.295861
#> 46:    45            0       6372     4.295861
#> 47:    46            0       6372     4.295861
#> 48:    47            0       6372     4.295861
#> 49:    48            0       6372     4.295861
#> 50:    49            0       6372     4.295861
#> 51:    50            0       6372     4.295861
#>      week weekly_cases cumulative effective_r0
#>                         cases_per_gen
#>                                <list>
#>  1:   15,  33,  89, 252, 724,1643,...
#>  2:   15,  33,  89, 252, 724,1643,...
#>  3:   15,  33,  89, 252, 724,1643,...
#>  4:   15,  33,  89, 252, 724,1643,...
#>  5:   15,  33,  89, 252, 724,1643,...
#>  6:   15,  33,  89, 252, 724,1643,...
#>  7:   15,  33,  89, 252, 724,1643,...
#>  8:   15,  33,  89, 252, 724,1643,...
#>  9:   15,  33,  89, 252, 724,1643,...
#> 10:   15,  33,  89, 252, 724,1643,...
#> 11:   15,  33,  89, 252, 724,1643,...
#> 12:   15,  33,  89, 252, 724,1643,...
#> 13:   15,  33,  89, 252, 724,1643,...
#> 14:   15,  33,  89, 252, 724,1643,...
#> 15:   15,  33,  89, 252, 724,1643,...
#> 16:   15,  33,  89, 252, 724,1643,...
#> 17:   15,  33,  89, 252, 724,1643,...
#> 18:   15,  33,  89, 252, 724,1643,...
#> 19:   15,  33,  89, 252, 724,1643,...
#> 20:   15,  33,  89, 252, 724,1643,...
#> 21:   15,  33,  89, 252, 724,1643,...
#> 22:   15,  33,  89, 252, 724,1643,...
#> 23:   15,  33,  89, 252, 724,1643,...
#> 24:   15,  33,  89, 252, 724,1643,...
#> 25:   15,  33,  89, 252, 724,1643,...
#> 26:   15,  33,  89, 252, 724,1643,...
#> 27:   15,  33,  89, 252, 724,1643,...
#> 28:   15,  33,  89, 252, 724,1643,...
#> 29:   15,  33,  89, 252, 724,1643,...
#> 30:   15,  33,  89, 252, 724,1643,...
#> 31:   15,  33,  89, 252, 724,1643,...
#> 32:   15,  33,  89, 252, 724,1643,...
#> 33:   15,  33,  89, 252, 724,1643,...
#> 34:   15,  33,  89, 252, 724,1643,...
#> 35:   15,  33,  89, 252, 724,1643,...
#> 36:   15,  33,  89, 252, 724,1643,...
#> 37:   15,  33,  89, 252, 724,1643,...
#> 38:   15,  33,  89, 252, 724,1643,...
#> 39:   15,  33,  89, 252, 724,1643,...
#> 40:   15,  33,  89, 252, 724,1643,...
#> 41:   15,  33,  89, 252, 724,1643,...
#> 42:   15,  33,  89, 252, 724,1643,...
#> 43:   15,  33,  89, 252, 724,1643,...
#> 44:   15,  33,  89, 252, 724,1643,...
#> 45:   15,  33,  89, 252, 724,1643,...
#> 46:   15,  33,  89, 252, 724,1643,...
#> 47:   15,  33,  89, 252, 724,1643,...
#> 48:   15,  33,  89, 252, 724,1643,...
#> 49:   15,  33,  89, 252, 724,1643,...
#> 50:   15,  33,  89, 252, 724,1643,...
#> 51:   15,  33,  89, 252, 724,1643,...
#>                         cases_per_gen