epiverse-trace / simulist

An R package for simulating line lists
https://epiverse-trace.github.io/simulist/
Other
5 stars 1 forks source link

Add onset-to-recovery delays to simulation #99

Closed joshwlambert closed 6 months ago

joshwlambert commented 7 months ago

This PR addresses a feature request from #36 to add explicit onset-to-recovery time delays. This feature adds the onset_to_recovery argument to the sim_linelist() and sim_outbreak() functions, which by default is NA to not provide explicit recovery dates as this is thought to be the most common scenario when collecting line list information. The onset_to_recovery argument works identically to onset_to_death and onset_to_hosp, whereby it can be an <epidist> object, or an anonymous function to parameterise the delay distribution.

There is a breaking change as part of this PR with respect to the output line list <data.frame> from sim_linelist() and sim_outbreak(). The $date_death column has been replace with two columns, $outcome and $date_outcome. Currently the $outcome column is a character string with either "died" or "recovered". The $date_outcome column contains the date of the corresponding event (in the same row). This was decided from discussions in #36.

The Visualising line list data vignette (vis-linelist.Rmd) is updated to aggregate the new line list structure, and now includes a code chunk that uses {tidyr}. As a result, {tidyr} is added as a suggested package dependency.

The .add_death() function has been updated and renamed to .add_outcome() to deal with deaths and recoveries.

.cross_check_sim_input() is updated to return compound warnings or errors if necessary instead of returning multiple warnings or stopping on the first error.

Tests have been updated in line with the updates to exported and internal functions, including updating the tests/testthat/testdata/.

github-actions[bot] commented 7 months ago

This pull request:

(Note that results may be inacurrate if you branched from an outdated version of the target branch.)

github-actions[bot] commented 7 months ago

This pull request:

(Note that results may be inacurrate if you branched from an outdated version of the target branch.)

Bisaloo commented 7 months ago

I haven't reviewed the PR, I trust you with the implementation. Just a reminder to update the NEWS.md with this change before merging :wink:

joshwlambert commented 6 months ago

This PR has been reviewed as part of PR #101 which builds on top of this feature branch. I will now merge both of these PRs.

I will update the NEWS.md in a follow-up PR before releasing the package.