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 parameter time dependence #93

Merged
merged 16 commits into from
Sep 25, 2023
Merged

Allow parameter time dependence #93

merged 16 commits into from
Sep 25, 2023

Conversation

pratikunterwegs
Copy link
Collaborator

@pratikunterwegs pratikunterwegs commented Aug 29, 2023

This PR is fixes #92, by allowing users to pass a list of functions to epidemic models that specify how model rate parameters vary over time. This is implemented in both R-only and Rcpp. The R-only version mirrors the Rcpp version and hence does not use {deSolve} events.

A good place to get started with reviewing is the vignette on time dependence.

See also #76.

@pratikunterwegs pratikunterwegs changed the title Add parameter time dependence Allow parameter time dependence Aug 29, 2023
@pratikunterwegs
Copy link
Collaborator Author

pratikunterwegs commented Aug 29, 2023

Example after running the code (not a reprex):

epidemic_default_cpp(
  population = uk_population,
  infection = pandemic,
  vaccination = vax_regime,
  time_dependence = list(
    beta = mod_beta
  ),
  time_end = 365, increment = 1
)

Rplot

@pratikunterwegs pratikunterwegs marked this pull request as ready for review September 20, 2023 12:29
@pratikunterwegs
Copy link
Collaborator Author

Merging this PR today.

@pratikunterwegs pratikunterwegs merged commit 95e020b into main Sep 25, 2023
@pratikunterwegs pratikunterwegs deleted the feature/time-dep branch September 25, 2023 10:56
@adamkucharski
Copy link
Member

Thanks for putting together, this looks very useful – no major comments for this version from a quick review of the vignette.

One thing that would be useful consider for next version is how to convert temporal data (e.g. vaccine coverage over time) into a continuous function for easy incorporation into {epidemics}/ODE model – as this conversion is often one of the more time-consuming pre-processing tasks when dealing with temporal interventions. {odin} has some useful interpolation functions we may want to lean on if relevant (as it's on CRAN): https://mrc-ide.github.io/odin/articles/odin.html

@pratikunterwegs
Copy link
Collaborator Author

Thanks for taking a look, very helpful.

Passing data such as vaccine coverage and interpolating it is actually pretty relevant for the ebola model which currently doesn't have a vaccinated compartment, so passing vaccine coverage changes will be useful. Just off the top of my head I think this can already be done in an ad hoc way within the function passed to time_dependence, using approx() to interpolate data that are used in the function f(t, x, data = data).

I'll convert the suggestion into an issue and perhaps we can address it on the development day, happy to have input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pass parameter time-dependence functions
2 participants