This PR closes #94 by expanding the options for a user to pass to onset_to_hosp or onset_to_death arguments in sim_linelist() and sim_outbreak() to now include NA. If a user passes NA to either argument the resulting $date_admission or $date_death column in the line list will be populated with NAs.
This change requires some new functions being added to the package:
is_na(): checks that a R object is a single logical NA
.cross_check_sim_input(): similar to .check_sim_input() but cross-checks the onset_to_* arguments with the *_risk arguments to ensure the user has provided consistent input. If not the function will warn or error depending on the combination input by the user and whether incorrect argument specification can be safely ignored with a message to the user.
as_function(): wraps and extends some pre-existing code from sim_linelist() and sim_outbreak() that was input checking the epidemiological distributions (contact_distribution, infect_period, onset_to_hosp and onset_to_death) and converting them to functions. As this code can now convert NA into NA generating functions the added complexity meant having this code contained in a single function and not (identically) repeated across two simulation functions made sense. (It also provides a better structure to extend for upcoming additions to the number of onset-to-event distributions, see #36).
The .add_hospitalisation() and .add_death() functions were updated to accommodate the possibility that onset_to_hosp or onset_to_death could be NA (technically NA producing functions). .check_sim_input() is also updated.
Tests and documentation are added for new functions, and tests for new sim_linelist() functionality are also added.
This PR closes #94 by expanding the options for a user to pass to
onset_to_hosp
oronset_to_death
arguments insim_linelist()
andsim_outbreak()
to now includeNA
. If a user passesNA
to either argument the resulting$date_admission
or$date_death
column in the line list will be populated withNA
s.This change requires some new functions being added to the package:
is_na()
: checks that a R object is a single logicalNA
.cross_check_sim_input()
: similar to.check_sim_input()
but cross-checks theonset_to_*
arguments with the*_risk
arguments to ensure the user has provided consistent input. If not the function will warn or error depending on the combination input by the user and whether incorrect argument specification can be safely ignored with a message to the user.as_function()
: wraps and extends some pre-existing code fromsim_linelist()
andsim_outbreak()
that was input checking the epidemiological distributions (contact_distribution
,infect_period
,onset_to_hosp
andonset_to_death
) and converting them to functions. As this code can now convertNA
intoNA
generating functions the added complexity meant having this code contained in a single function and not (identically) repeated across two simulation functions made sense. (It also provides a better structure to extend for upcoming additions to the number of onset-to-event distributions, see #36).The
.add_hospitalisation()
and.add_death()
functions were updated to accommodate the possibility thatonset_to_hosp
oronset_to_death
could beNA
(technicallyNA
producing functions)..check_sim_input()
is also updated.Tests and documentation are added for new functions, and tests for new
sim_linelist()
functionality are also added.Miscellaneous changes in this PR:
CITATION.cff
fileRoxygenNote
field inDESCRIPTION