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

Vector inputs for ODE models #176

Merged
merged 88 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
1a98748
Model output processing fn renamed, returns DT
pratikunterwegs Feb 9, 2024
d61240d
Update docs for model output processing fn
pratikunterwegs Feb 9, 2024
ce1a8c1
Default model cpp accepts param vecs, WIP #166
pratikunterwegs Feb 9, 2024
46d380a
Vacamole model cpp accepts param vecs, WIP #166
pratikunterwegs Feb 9, 2024
6875275
Diphtheria model cpp accepts param vecs, WIP #166
pratikunterwegs Feb 9, 2024
6e8f955
Ebola model uses renamed output processing
pratikunterwegs Feb 9, 2024
36b7906
Fn to transpose a list
pratikunterwegs Feb 9, 2024
40f9624
Fns for recycling vectors
pratikunterwegs Feb 9, 2024
60ef87f
Update recyclability testing in ODE cpp fns
pratikunterwegs Feb 9, 2024
44f200c
Add cross-checking fns, WIP #175
pratikunterwegs Feb 9, 2024
f919472
Rm `.check_args_model_default()`, WIP #175
pratikunterwegs Feb 9, 2024
d1805b1
Default model Cpp handles vector of interventions, WIP #167
pratikunterwegs Feb 9, 2024
4b1a3d7
Fns to cross check model elements
pratikunterwegs Feb 12, 2024
2ce5efe
Simplify checking/prepping default mod args
pratikunterwegs Feb 12, 2024
3b19134
Default model C++ handles lists of vax and populations, WIP #167
pratikunterwegs Feb 12, 2024
b9b3807
Add tests for vectorised input, WIP #166, WIP #167
pratikunterwegs Feb 12, 2024
f6bbad3
Default model fn C++ returns simple DF for scalars, WIP #177
pratikunterwegs Feb 13, 2024
20ef36e
Restore tests for scalar args default model C++
pratikunterwegs Feb 13, 2024
0503135
Skip checks default model R implementation
pratikunterwegs Feb 13, 2024
9e94845
Correct .cross_check_vaccination(), WIP #175
pratikunterwegs Feb 13, 2024
278ad5f
Vacamole model C++ accepts lists of components, WIP #167
pratikunterwegs Feb 13, 2024
1fbd058
Rename args checker fn for Vacamole
pratikunterwegs Feb 13, 2024
0d9465e
Update args checker fn default model
pratikunterwegs Feb 13, 2024
b0fe5b9
Update author list; add @TimTaylor @adamkucharski
pratikunterwegs Feb 13, 2024
97dcede
Update CITATION.cff
actions-user Feb 13, 2024
cf2c388
.cross_check_intervention: add check for rate intervs
pratikunterwegs Feb 14, 2024
39e1261
Vacamole: vaccination is optional, use correct internal fn
pratikunterwegs Feb 14, 2024
940d8d8
WIP: new test suite for Vacamole model
pratikunterwegs Feb 14, 2024
719f76a
Minor input checks to default model
pratikunterwegs Feb 15, 2024
340b5c4
Allow vaccination as NULL for Vacamole
pratikunterwegs Feb 15, 2024
bd476ad
Full rewrite tests for default model
pratikunterwegs Feb 15, 2024
4fb6ab4
Full rewrite of tests for Vacamole
pratikunterwegs Feb 15, 2024
afb3152
Remove previous tests for vectorised fn
pratikunterwegs Feb 15, 2024
a99d6c0
Rename default and Vacamole test files
pratikunterwegs Feb 15, 2024
983d2ca
Rename test file for ebola model
pratikunterwegs Feb 15, 2024
da8d628
Refactor diphtheria model to vectorised form, WIP #166, WIP #167
pratikunterwegs Feb 16, 2024
b4c254c
Refactor diphtheria args checker, WIP #175
pratikunterwegs Feb 16, 2024
4b8e29a
Minor corrections to args checkers, WIP #175
pratikunterwegs Feb 16, 2024
6cdc0b4
`.output_to_df()` takes names from demography, rm `get_parameter()`
pratikunterwegs Feb 16, 2024
a43a246
Test suite for the diphtheria model, WIP #178
pratikunterwegs Feb 16, 2024
6be94c8
Access params without `get_parameter()`
pratikunterwegs Feb 16, 2024
12a1fce
Rm old Rd files
pratikunterwegs Feb 16, 2024
5981048
More input checks for `population()`
pratikunterwegs Feb 16, 2024
f02e9b3
.cross_check_interv checks if contact intervs are allowed
pratikunterwegs Feb 16, 2024
39f47ef
Remove wrappers to R-only ODEs; WIP #162
pratikunterwegs Feb 16, 2024
69e4ca3
Rm .transpose_base(), unify vector recyling fns, no_time_dep() now in…
pratikunterwegs Feb 16, 2024
bb25f6e
Update pkgdown YAML
pratikunterwegs Feb 16, 2024
891bdcd
Fix .no_time_dependence() list naming
pratikunterwegs Feb 19, 2024
118037a
Update function documentation for model params
pratikunterwegs Feb 19, 2024
d60a6e6
Rmv lang suffixes in model func names; standardise filenames
pratikunterwegs Feb 19, 2024
94ac0d2
Further renaming of model fns in tests and helper fns
pratikunterwegs Feb 19, 2024
6f6a6c3
Rationalise tests for time-dependence
pratikunterwegs Feb 19, 2024
2537c5d
Rename ebola snapshot file
pratikunterwegs Feb 19, 2024
209307a
Remove benchmarking vignette
pratikunterwegs Feb 19, 2024
08e478f
Rename vignette files; use new fn names
pratikunterwegs Feb 19, 2024
10bdbbe
Update Readme with fn name
pratikunterwegs Feb 19, 2024
efb6d06
Update pkg infrastructure
pratikunterwegs Feb 19, 2024
fdbc4b8
Update tests for new_infections()
pratikunterwegs Feb 19, 2024
a258e5a
Add tests for vector recycling tools
pratikunterwegs Feb 19, 2024
0b573de
Minor updates to pkg docs and internal tools
pratikunterwegs Feb 19, 2024
ae87a92
Update CITATION.cff
actions-user Feb 19, 2024
def1c3c
Update header guards
pratikunterwegs Feb 19, 2024
5ddc41d
Renaming dummy elements file; document cross-check fns, WIP #175
pratikunterwegs Feb 20, 2024
48beb0d
Trigger Readme build
pratikunterwegs Feb 20, 2024
cf3dbda
Update WORDLIST
pratikunterwegs Feb 20, 2024
522cb71
Remove internal args from model output
pratikunterwegs Feb 20, 2024
7ff4673
Add scenario modelling + param uncertainty vignette, fixes #183
pratikunterwegs Feb 20, 2024
306551a
Automatic readme update
actions-user Feb 20, 2024
bf1b377
Update CITATION.cff
actions-user Feb 20, 2024
bd62d0d
Update dev NEWS and rm {deSolve} from Suggests
pratikunterwegs Feb 27, 2024
6441867
Update CITATION.cff
actions-user Feb 27, 2024
8a40c27
Add motivation for param uncertainty modelling
pratikunterwegs Mar 5, 2024
828cb2f
Add tests for effect of cumulative contact intervs, WIP #187
pratikunterwegs Mar 5, 2024
3324dae
Update scenario modelling vignette, WIP #187
pratikunterwegs Mar 6, 2024
68a3746
Use magrittr pipe throughout
pratikunterwegs Mar 6, 2024
1d45778
Add {ggdist} and {purrr} to Suggests
pratikunterwegs Mar 6, 2024
ea471d2
Update CITATION.cff
actions-user Mar 6, 2024
52cfb32
Pull dummy element creator fns internal, prefix with `.`
pratikunterwegs Mar 11, 2024
bfe2b1d
Update model docs and comments
pratikunterwegs Mar 11, 2024
356d5c7
Update tests for dummy element creators
pratikunterwegs Mar 11, 2024
436d35c
Rm unused params in documentation
pratikunterwegs Mar 11, 2024
26365ef
Scenario modelling vignette adds plots, by_group size
pratikunterwegs Mar 11, 2024
d3bac57
Correction to Vacamole vignette from internal .no_vax
pratikunterwegs Mar 11, 2024
8c6e13f
Add EpiEstim comment, correct R description
pratikunterwegs Mar 11, 2024
8abb8cd
Automatic readme update
actions-user Mar 11, 2024
51cccaf
Add comments on complex input checks
pratikunterwegs Mar 12, 2024
8c26a98
Update vignette and WORDLIST
pratikunterwegs Mar 12, 2024
227e2cb
Correct typo in vignette
pratikunterwegs Mar 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 52 additions & 23 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ message: 'To cite package "epidemics" in publications use:'
type: software
license: MIT
title: 'epidemics: A Library of Compartmental Epidemic Scenario Models'
version: 0.1.0
version: 0.1.0.9000
abstract: A library of compartmental epidemic models taken from the published literature,
and classes to represent populations with heterogeneous characteristics, public
health response measures including non-pharmaceutical interventions on social contacts,
Expand Down Expand Up @@ -98,27 +98,6 @@ references:
given-names: Toby
orcid: https://orcid.org/0000-0002-3146-0865
year: '2024'
- type: software
title: deSolve
abstract: 'deSolve: Solvers for Initial Value Problems of Differential Equations
(''ODE'', ''DAE'', ''DDE'')'
notes: Imports
url: http://desolve.r-forge.r-project.org/
repository: https://CRAN.R-project.org/package=deSolve
authors:
- family-names: Soetaert
given-names: Karline
email: [email protected]
orcid: https://orcid.org/0000-0003-4603-7100
- family-names: Petzoldt
given-names: Thomas
email: [email protected]
orcid: https://orcid.org/0000-0002-4951-6468
- family-names: Setzer
given-names: R. Woodrow
email: [email protected]
orcid: https://orcid.org/0000-0002-6709-9186
year: '2024'
- type: software
title: glue
abstract: 'glue: Interpreted String Literals'
Expand Down Expand Up @@ -319,6 +298,17 @@ references:
email: [email protected]
orcid: https://orcid.org/0000-0001-8814-9421
year: '2024'
- type: software
title: ggdist
abstract: 'ggdist: Visualizations of Distributions and Uncertainty'
notes: Suggests
url: https://mjskay.github.io/ggdist/
repository: https://CRAN.R-project.org/package=ggdist
authors:
- family-names: Kay
given-names: Matthew
email: [email protected]
year: '2024'
- type: software
title: ggplot2
abstract: 'ggplot2: Create Elegant Data Visualisations Using the Grammar of Graphics'
Expand Down Expand Up @@ -369,6 +359,21 @@ references:
email: [email protected]
orcid: https://orcid.org/0000-0003-0645-5666
year: '2024'
- type: software
title: purrr
abstract: 'purrr: Functional Programming Tools'
notes: Suggests
url: https://purrr.tidyverse.org/
repository: https://CRAN.R-project.org/package=purrr
authors:
- family-names: Wickham
given-names: Hadley
email: [email protected]
orcid: https://orcid.org/0000-0003-4757-117X
- family-names: Henry
given-names: Lionel
email: [email protected]
year: '2024'
- type: software
title: rmarkdown
abstract: 'rmarkdown: Dynamic Documents for R'
Expand Down Expand Up @@ -448,7 +453,7 @@ references:
title: spelling
abstract: 'spelling: Tools for Spell Checking in R'
notes: Suggests
url: https://docs.ropensci.org/spelling/
url: https://ropensci.r-universe.dev/spelling
repository: https://CRAN.R-project.org/package=spelling
authors:
- family-names: Ooms
Expand Down Expand Up @@ -502,6 +507,30 @@ references:
- family-names: Girlich
given-names: Maximilian
year: '2024'
- type: software
title: withr
abstract: 'withr: Run Code ''With'' Temporarily Modified Global State'
notes: Suggests
url: https://withr.r-lib.org
repository: https://CRAN.R-project.org/package=withr
authors:
- family-names: Hester
given-names: Jim
- family-names: Henry
given-names: Lionel
email: [email protected]
- family-names: Müller
given-names: Kirill
email: [email protected]
- family-names: Ushey
given-names: Kevin
email: [email protected]
- family-names: Wickham
given-names: Hadley
email: [email protected]
- family-names: Chang
given-names: Winston
year: '2024'
- type: software
title: BH
abstract: 'BH: Boost C++ Header Files'
Expand Down
8 changes: 5 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: epidemics
Title: A Library of Compartmental Epidemic Scenario Models
Version: 0.1.0
Version: 0.1.0.9000
Authors@R: c(
person("Pratik", "Gupte", , "[email protected]", role = c("aut", "cre", "cph"),
comment = c(ORCID = "0000-0001-5294-7819")),
Expand Down Expand Up @@ -32,7 +32,6 @@ Imports:
checkmate,
cli,
data.table,
deSolve,
glue,
Rcpp,
RcppEigen,
Expand All @@ -45,15 +44,18 @@ Suggests:
dplyr,
EpiEstim,
finalsize,
ggdist,
ggplot2,
knitr,
purrr,
rmarkdown,
scales,
socialmixr,
spelling,
testthat (>= 3.0.0),
tibble,
tidyr
tidyr,
withr
LinkingTo:
BH,
Rcpp,
Expand Down
14 changes: 4 additions & 10 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,17 @@ S3method(print,vaccination)
export(as.intervention)
export(as.vaccination)
export(epidemic_size)
export(get_parameter)
export(intervention)
export(is_contacts_intervention)
export(is_intervention)
export(is_population)
export(is_rate_intervention)
export(is_vaccination)
export(model_default_cpp)
export(model_default_r)
export(model_diphtheria_cpp)
export(model_ebola_r)
export(model_vacamole_cpp)
export(model_vacamole_r)
export(model_default)
export(model_diphtheria)
export(model_ebola)
export(model_vacamole)
export(new_infections)
export(no_contacts_intervention)
export(no_rate_intervention)
export(no_vaccination)
export(population)
export(vaccination)
import(RcppEigen)
Expand Down
51 changes: 51 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,54 @@
# epidemics (development version)

The development version of _epidemics_ makes substantial additions to the functionality in v0.1.0, and introduces significant breaking changes in #176.

## Breaking changes

1. The "Vacamole" model has been refactored with the arguments `*_reduction_vax` for the effect of double vaccination on compartmental transition rates renamed to `*_vax`, where `*` may be one of susceptibility, hospitalisation, and mortality. Previously, these parameters were implemented in the internal C++ code, but presented as inverse values to users (i.e., `susceptibility_vax = susceptibility * (1 - (susceptibility_reduction_vax)))`). This change brings the user-facing representation in line with the internal implementation, and allows these parameters to be targeted by rate interventions and time-dependence, which was not possible earlier.

2. All model function have been renamed to `model_<NAME>()`, removing the language suffix.

3. The wrappers around R-only implementations of the 'default' and 'Vacamole' models have been removed, but the ODE system functions have been retained.

4. The function `get_parameter()` has been removed.

## Model structures

There is no change to the model structures.

## Classes

No substantial changes to classes; small additions of input checking to `<population>` class.

## Helper functions

1. Internal helper functions `.check_args_model_*()` and `.prepare_args_model_*()` have been combined into single functions `.check_prepare_args_*()` that are called both for their output and for input checking side effects.

2. The new internal functions `.prepare_population()`, `.cross_check_intervention()`, `.cross_check_vaccination()`, `.cross_check_timedep()`, and `.cross_check_popchange()` check and prepare a model population and check other inputs for compatibility with it. These are used in `.check_prepare_args_*()`.

3. New internal functions have been added to check and recycle lists of vectors; original implementations by @TimTaylor.

4. `output_to_df()` is renamed to `.output_to_df()`.

## Documentation

1. The benchmarking vignette has been removed as the R-only model implementations are no longer provided to users.

2. The vignette on parameter uncertainty has been rewritten to show how to pass vectors of infection parameters and model composable elements to model functions, and renamed to "Modelling parameter uncertainty and epidemic scenarios".

3. All function documentation has been updated to reflect name changes and other minor improvements.

## Package

1. All ODE model functions have received a more extensive and more standardised (as much as possible) test suite.

2. Filenames have been standardised to show which files are related, e.g. `R/model_default.R`, `src/model_default.cpp`, and `inst/include/model_default.h`; references to filenames such as in the package header have been updated.

3. Removed {deSolve} from dependencies.

4. Updated NEWS.md file to track changes to the package.


# epidemics 0.1.0

This is an initial GitHub release of _epidemics_, an R package that ships a library of compartmental epidemic model structures that can be used, along with supplied classes that help define population characteristics and epidemic response interventions including vaccinations, to compose and model epidemic scenarios.
Expand Down
6 changes: 3 additions & 3 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#' The second list element is a vector of timesteps.
#' @keywords internal
.model_default_cpp <- function(initial_state, transmissibility, infectiousness_rate, recovery_rate, contact_matrix, npi_time_begin, npi_time_end, npi_cr, vax_time_begin, vax_time_end, vax_nu, rate_interventions, time_dependence, time_end = 100.0, increment = 1.0) {
.Call(`_epidemics_model_default_cpp_internal`, initial_state, transmissibility, infectiousness_rate, recovery_rate, contact_matrix, npi_time_begin, npi_time_end, npi_cr, vax_time_begin, vax_time_end, vax_nu, rate_interventions, time_dependence, time_end, increment)
.Call(`_epidemics_model_default_internal`, initial_state, transmissibility, infectiousness_rate, recovery_rate, contact_matrix, npi_time_begin, npi_time_end, npi_cr, vax_time_begin, vax_time_end, vax_nu, rate_interventions, time_dependence, time_end, increment)
}

#' @title Run an SEIHR ODE model for diphtheria using a Boost solver
Expand Down Expand Up @@ -74,7 +74,7 @@
#' The second list element is a vector of timesteps.
#' @keywords internal
.model_diphtheria_cpp <- function(initial_state, transmissibility, infectiousness_rate, recovery_rate, reporting_rate, prop_hosp, hosp_entry_rate, hosp_exit_rate, rate_interventions, time_dependence, pop_change_times, pop_change_values, time_end = 100.0, increment = 1.0) {
.Call(`_epidemics_model_diphtheria_cpp_internal`, initial_state, transmissibility, infectiousness_rate, recovery_rate, reporting_rate, prop_hosp, hosp_entry_rate, hosp_exit_rate, rate_interventions, time_dependence, pop_change_times, pop_change_values, time_end, increment)
.Call(`_epidemics_model_diphtheria_internal`, initial_state, transmissibility, infectiousness_rate, recovery_rate, reporting_rate, prop_hosp, hosp_entry_rate, hosp_exit_rate, rate_interventions, time_dependence, pop_change_times, pop_change_values, time_end, increment)
}

#' @title Run the RIVM Vacamole model
Expand Down Expand Up @@ -128,6 +128,6 @@
#' The second list element is a vector of timesteps.
#' @keywords internal
.model_vacamole_cpp <- function(initial_state, transmissibility, transmissibility_vax, infectiousness_rate, mortality_rate, mortality_rate_vax, hospitalisation_rate, hospitalisation_rate_vax, recovery_rate, contact_matrix, npi_time_begin, npi_time_end, npi_cr, vax_time_begin, vax_time_end, vax_nu, rate_interventions, time_dependence, time_end = 100.0, increment = 1.0) {
.Call(`_epidemics_model_vacamole_cpp_internal`, initial_state, transmissibility, transmissibility_vax, infectiousness_rate, mortality_rate, mortality_rate_vax, hospitalisation_rate, hospitalisation_rate_vax, recovery_rate, contact_matrix, npi_time_begin, npi_time_end, npi_cr, vax_time_begin, vax_time_end, vax_nu, rate_interventions, time_dependence, time_end, increment)
.Call(`_epidemics_model_vacamole_internal`, initial_state, transmissibility, transmissibility_vax, infectiousness_rate, mortality_rate, mortality_rate_vax, hospitalisation_rate, hospitalisation_rate_vax, recovery_rate, contact_matrix, npi_time_begin, npi_time_end, npi_cr, vax_time_begin, vax_time_end, vax_nu, rate_interventions, time_dependence, time_end, increment)
}

Loading
Loading