Add line list event dates and case information as columns to infectious history <data.frame>
Source: R/add_cols.R
dot-add_cols.RdThese .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,
first_contact_distribution,
last_contact_distribution,
outbreak_start_date
)
.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)
.add_reporting_delay(.data, reporting_delay)Arguments
- .data
A
<data.frame>containing the infectious history from a branching process simulation (.sim_network_bp()).- first_contact_distribution, last_contact_distribution
A
functionto generate the time for the first or last contact between the infector and infectee (exposure window). Seecreate_config().- outbreak_start_date
A
datefor the start of the outbreak.- onset_to_hosp
A
functionor an<epiparameter>object for the onset-to-hospitalisation delay distribution.onset_to_hospcan also be set toNULLto 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()) withmeanlog = 1.5andsdlog = 0.5.If
onset_to_hospis set toNULLthenhosp_riskandhosp_death_riskwill be automatically set toNULLif not manually specified.- hosp_risk
Either a single
numericfor 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 theonset_to_hospargument is set toNULLthis argument will automatically be set toNULLif not specified or can be manually set toNULL. See details and examples for more information.- onset_to_death
A
functionor an<epiparameter>object for the onset-to-death delay distribution.onset_to_deathcan also be set toNULLto 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()) withmeanlog = 2.5andsdlog = 0.5.If
onset_to_deathis set toNULLthennon_hosp_death_riskandhosp_death_riskwill be automatically set toNULLif not manually specified.For hospitalised cases, the function ensures the onset-to-death time is greater than the onset-to-hospitalisation time. After many (1000) attempts, if an onset-to-death time (from
onset_to_death) cannot be sampled that is greater than a onset-to-hospitalisation time (fromonset_to_hosp) then the function will error. Due to this conditional sampling, the onset-to-death times in the line list may not resemble the distributional form input into the function.- onset_to_recovery
A
functionor an<epiparameter>object for the onset-to-recovery delay distribution.onset_to_recoverycan also beNULLto 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
NULLso by default cases that recover get anNAin the$date_outcomeline list column.For hospitalised cases, the function ensures the onset-to-recovery time is greater than the onset-to-hospitalisation time. After many (1000) attempts, if an onset-to-recovery time (from
onset_to_recovery) cannot be sampled that is greater than a onset-to-hospitalisation time (fromonset_to_hosp) then the function will error. Due to this conditional sampling, the onset-to-recovery times in the line list may not resemble the distributional form input into the function.- hosp_death_risk
Either a single
numericfor 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 theonset_to_deathargument is set toNULLthis argument will automatically be set toNULLif not specified or can be manually set toNULL. See details and examples for more information. Thehosp_death_riskcan vary through time if specified in thetime_varying_death_riskelement ofconfig, seevignette("time-varying-cfr", package = "simulist")for more information.- non_hosp_death_risk
Either a single
numericfor 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 theonset_to_deathargument is set toNULLthis argument will automatically be set toNULLif not specified or can be manually set toNULL. See details and examples for more information. Thenon_hosp_death_riskcan vary through time if specified in thetime_varying_death_riskelement ofconfig, seevignette("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
logicalboolean for whether case names should be anonymised. Default isFALSE.- reporting_delay
A
functionfor the reporting delay distribution orNULL. The (random) number generating function creates delays between the time of symptom onset ($date_onset) and the case being reported ($date_reporting).The function can be defined or anonymous. The function must return a vector of
numerics for the length of the reporting delay. The function must have a single argument.The default is
NULLso by default there is no reporting delay, and the$date_reportingline list column is identical to the$date_onsetcolumn.