Skip to content

Commit

Permalink
Update finalsize comparison vignette
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikunterwegs committed Oct 25, 2023
1 parent de9ae32 commit f979183
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions vignettes/finalsize_comparison.Rmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "Comparing epidemic sizes from ODE models against an analytical method"
title: "When to use ODE models or analytical methods for epidemic size modelling"
output:
bookdown::html_vignette2:
fig_caption: yes
Expand All @@ -9,7 +9,7 @@ pkgdown:
bibliography: references.json
link-citations: true
vignette: >
%\VignetteIndexEntry{Comparing epidemic sizes from ODE models against an analytical method}
%\VignetteIndexEntry{When to use ODE models or analytical methods for epidemic size modelling}
%\VignetteEncoding{UTF-8}
%\VignetteEngine{knitr::rmarkdown}
editor_options:
Expand Down Expand Up @@ -48,9 +48,10 @@ library(dplyr)
library(tibble)
library(tidyr)
library(socialmixr)
library(bench)
```

## Choosing between _finalsize_ and _epidemics_
## Different use cases of _finalsize_ and _epidemics_

While both _finalsize_ and _epidemics_ can be used to calculate the epidemic final size, they are aimed at different use cases.

Expand Down Expand Up @@ -305,16 +306,16 @@ epidemic_size(data = output, stage = 0.1)
epidemic_size(data = output, stage = 0.5)
```

## Choosing an appropriate method for final size calculations
## Consideration of computational speed

An important reason to use _finalsize_ for final size calculations may be speed --- `finalsize::final_size()` is much faster than `epidemics::epidemic_size()` applied to `epidemics::epidemic_default_cpp()`.
This makes it much more suitable for high-performance applications such as fitting to data.

The benchmarking shows that the total time taken for 1,000 runs using both methods is very low, and both methods could be used to scan across multiple values of the input parameters, such as when dealing with parameter uncertainty.

```{r warning=FALSE, message=FALSE}
# create functions from the
bench::mark(
# run benchmarks using {bench}
benchmark <- mark(
analytical_method = final_size(
r0 = pandemic_influenza$r0,
contact_matrix = contact_matrix,
Expand All @@ -334,8 +335,13 @@ bench::mark(
time_unit = "s",
check = FALSE
)
# view the total time for 1000 runs in seconds
select(as_tibble(benchmark), expression, total_time)
```

**Note** that some model runs using _epidemics_ that implement more complex compartmental structure, or multiple interventions and vaccination regimes are likely to be slower than the example shown here.

However, users should choose _finalsize_ only when the assumptions underlying a final size calculation are met.
For example, in cases where vaccinations are concurrent with a large number of infections, or when interventions are applied to reduce transmission, the final size assumptions are not met.
In these cases, users are advised to use a dynamical model such as those in _epidemics_ instead.
Expand Down

0 comments on commit f979183

Please sign in to comment.