-
Notifications
You must be signed in to change notification settings - Fork 2
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
Restructure {epidemics} to Rcpp #15
Conversation
Codecov Report
@@ Coverage Diff @@
## main #15 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 3 14 +11
Lines 132 319 +187
==========================================
+ Hits 132 319 +187
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Thanks @joshwlambert and @Bisaloo for taking a look at this. Adding some comments here to explain recent changes, below. Edwin and I will be going over the PR tomorrow as well, so hope to get some comments on the C++ code before merging.
The default values were to make development easier - this has now been changed with a move to a system where model parameters are passed in
I've converted this to issue #18 - will address this in a PR aimed at improving documentation.
I've changed to returning
This is no longer exported.
Both now have some checking added from the constructor in the validator as well.
I'll add this to an issue, #19, that should be addressed in a PR tackling documentation I've left the vignettes more or less as they are for now, as these are primarily to help reviewers get to grips with the functionality. I'll likely update these in fits and starts, as the underlying functionality changes (e.g. adding an I'm still adding some tests for the package classes, which will be covered in this PR, but these are likely to be fairly straightforward. Package print methods won't be covered here. I can update the README with a quick start, but I think it would be better to do this once the |
Updating the code after consulting with @BlackEdder to:
|
This pull request implements an SEIRV model in (R)C++, and makes it available for use via the function
epidemic_cpp()
.This PR:
epi_demic()
#14 by separating the R-only epidemic model intoR/model_epidemic_default()
. This is likely to be replaced by the C++ model, and this code also satisfies the separation of the compartmental model from the stepper, integrator, and observer;vaccination
class;intervention()
;no_intervention()
to be passed for theintervention
argument - only tested forepidemic_cpp()
;epidemic_cpp()
(the futureepidemic()
) to accept arguments to the specific epidemic models from...
.Epidemic model
epidemic_cpp()
is intended to be an initial implementation of a wrapper function, entirely in R, that calls the internal Rcpp function.epidemic_default_cpp()
, which is an Rcpp function (a C++ function exposed to R)..epidemic_default_cpp()
is where the ODE system, defined in the headerinst/include/epidemic_default.h
is passed to an integrator along with a stepper and an observer. Terminology is taken from Boost's odeint library.Future development will include:
.epidemic_default_cpp()
, this may include the model implemented in {vacamole};pathogen
class to replace the argumentsr0
,preinfectious_period
, andinfectious_period
- this class could potentially take inputs from anepidist
object from {epiparameter}.epi_demic()
function as it is superseded byepidemic_cpp()
(which will be renamed accordingly).Convenience classes and functions
There are a number of convenience classes implemented in {epidemics}, which are all essentially lists, as these are easily passed to C++ using Rcpp. This reduces the need to write C++ structs or classes that mirror their R versions.
population
: A class to hold population details, including a name, demography vector, contact matrix, and initial epidemiological conditions.intervention
: A class to hold non-pharmaceutical intervention details, including a name, a start time, an end time, and a vector for the group-specific contact reduction.vaccination
: A class to hold vaccination regime details, including a name, vectors for the group-specific start and end times, and a vector for the group specific vaccination rates.The C++ headers under
inst/include
hold functions to handle these classes in C++ as Rcpp lists.Future development will include:
pathogen
orinfection
class;Vignettes
Four basic vignettes show how to use the R only and Rcpp versions of the model. Note that the R only version does not include an 'exposed' compartment, and there is no intention to include one.
Notes:
.epidemic_default_cpp()
to.epidemic_wrapper_cpp()
or similar - this will depend on where exactly model choice is implemented).