Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow onset_to_hosp and onset_to_death to be NA #98

Merged
merged 19 commits into from
Apr 5, 2024
Merged

Conversation

joshwlambert
Copy link
Member

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 Functionality for time varying CFR and different delays depending on outcome #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.

Miscellaneous changes in this PR:

  • Updates to CITATION.cff file
  • Update RoxygenNote field in DESCRIPTION

@joshwlambert joshwlambert added the enhancement New feature or request label Apr 5, 2024
@joshwlambert joshwlambert merged commit 4c54346 into main Apr 5, 2024
9 checks passed
@joshwlambert joshwlambert deleted the na-cols branch April 5, 2024 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Specifying columns when simulating outbreak data
2 participants