Skip to contents

These .add_*() functions add columns to the <data.frame> output by .sim_network_bp(). The <data.frame> supplied to .data will have a different number of columns depending on which function is being called (i.e. the <data.frame> supplied to .add_hospitalisation() will have more columns than the <data.frame> supplied to .add_date_contact() as former function is called later in the simulation).

The event date could be first contact, last contact or other.

Usage

.add_date_contact(
  .data,
  contact_type = c("first", "last"),
  distribution = c("pois", "geom"),
  ...,
  outbreak_start_date = NULL
)

.add_hospitalisation(.data, onset_to_hosp, hosp_risk)

.add_outcome(
  .data,
  onset_to_death,
  onset_to_recovery,
  hosp_death_risk,
  non_hosp_death_risk,
  config
)

.add_names(.data, anonymise = FALSE)

.add_ct(.data, distribution = c("norm", "lnorm"), ...)

Arguments

.data

A <data.frame> containing the infectious history from a branching process simulation (.sim_network_bp()).

contact_type

A character with the type of contact, either first contact ("first"), or last contact ("last").

distribution

A character with the name of the distribution, following the base R convention for distribution naming (e.g. Poisson is pois).

...

dots Extra arguments to be passed to the distribution function given in the distribution argument.

outbreak_start_date

A date for the start of the outbreak.

onset_to_hosp

A function or an <epiparameter> object for the onset-to-hospitalisation delay distribution. onset_to_hosp can also be set to NULL to not simulate hospitalisation (admission) dates.

The function can be defined or anonymous. The function must return a vector of numerics for the length of the onset-to-hospitalisation delay. The function must have a single argument.

An <epiparameter> can be provided. This will be converted into a random number generator internally.

The default is an anonymous function with a lognormal distribution random number generator (rlnorm()) with meanlog = 1.5 and sdlog = 0.5.

If onset_to_hosp is set to NULL then hosp_risk and hosp_death_risk will be automatically set to NULL if not manually specified.

hosp_risk

Either a single numeric for the hospitalisation risk of everyone in the population, or a <data.frame> with age specific hospitalisation risks. Default is 20% hospitalisation (0.2) for the entire population. If the onset_to_hosp argument is set to NULL this argument will automatically be set to NULL if not specified or can be manually set to NULL. See details and examples for more information.

onset_to_death

A function or an <epiparameter> object for the onset-to-death delay distribution. onset_to_death can also be set to NULL to not simulate dates for individuals that died.

The function can be defined or anonymous. The function must return a vector of numerics for the length of the onset-to-death delay. The function must have a single argument.

An <epiparameter> can be provided. This will be converted into a random number generator internally.

The default is an anonymous function with a lognormal distribution random number generator (rlnorm()) with meanlog = 2.5 and sdlog = 0.5.

If onset_to_death is set to NULL then non_hosp_death_risk and hosp_death_risk will be automatically set to NULL if not manually specified.

onset_to_recovery

A function or an <epiparameter> object for the onset-to-recovery delay distribution. onset_to_recovery can also be NULL to not simulate dates for individuals that recovered.

The function can be defined or anonymous. The function must return a vector of numerics for the length of the onset-to-recovery delay. The function must have a single argument.

An <epiparameter> can be provided. This will be converted into a random number generator internally.

The default is NULL so by default cases that recover get an NA in the $date_outcome line list column.

hosp_death_risk

Either a single numeric for the death risk for hospitalised individuals across the population, or a <data.frame> with age specific hospitalised death risks Default is 50% death risk in hospitals (0.5) for the entire population. If the onset_to_death argument is set to NULL this argument will automatically be set to NULL if not specified or can be manually set to NULL. See details and examples for more information. The hosp_death_risk can vary through time if specified in the time_varying_death_risk element of config, see vignette("time-varying-cfr", package = "simulist") for more information.

non_hosp_death_risk

Either a single numeric for the death risk for outside of hospitals across the population, or a <data.frame> with age specific death risks outside of hospitals. Default is 5% death risk outside of hospitals (0.05) for the entire population. If the onset_to_death argument is set to NULL this argument will automatically be set to NULL if not specified or can be manually set to NULL. See details and examples for more information. The non_hosp_death_risk can vary through time if specified in the time_varying_death_risk element of config, see vignette("time-varying-cfr", package = "simulist") for more information.

config

A list of settings to adjust the randomly sampled delays and Ct values. See create_config() for more information.

anonymise

A logical boolean for whether case names should be anonymised. Default is FALSE.

Value

A <data.frame> with one more column than input into .data. Unless the column heading is already present in which the data is overwritten.