epiverse-trace / epiparameter

R package with library of epidemiological parameters for infectious diseases and functions and classes for working with parameters
https://epiverse-trace.github.io/epiparameter
Other
33 stars 11 forks source link

Improve ability to modify discretisation and discretisation documentation #324

Closed joshwlambert closed 5 months ago

joshwlambert commented 5 months ago

This PR addresses #230 by improving the documentation and flexibility to interact with the packages that create the S3 distribution objects {distributional} and {distcrete}, by adding a ... argument to create_epidist_prob_dist() (renamed from create_prob_dist()) and to epidist() and new_epidist() (the internal <epidist> constructor).

create_epidist_prob_dist(), previously create_prob_dist(), is now an exported function and has been renamed to use the same naming style as other <epidist> helper functions (e.g. create_epidist_summary_stats(), creat_epidist_metadata(), etc.). It is now exported to allow users to easily update the prob_dist element in an existing <epidist>, e.g.:

edist <- epidist(<args>)
edist$prob_dist <- create_epidist_prob_dist(<args>)

The function documentation of create_epidist_prob_dist() now contains more information and links to {distcrete} and {distributional}. Note currently extra arguments can only be passed to distcrete::distcrete() and not {distributional} functions, but the documentation of create_epidist_prob_dist() does make this distinction clear as it may be in the future that distributional functions can take extra arguments. I'd be happy to change the create_epidist_prob_dist() documentation to make it more similar to epidist() documentation on ... which is more directed at distcrete::distcrete().

epidist() and new_epidist() gain the ... argument in order for users to modify discretisation details when constructing an <epidist>.

A new unit test is added to check create_epidist_prob_dist() correctly passes argument via ..., and tests have been updated to use the up-to-date functions that have been renamed.