The sirplus package makes it easy to generate stochastic individual compartment
models (ICMs) to simulate contagious disease spread using compartments not
available in standard SIR packages. This method and most of the code was
originally written by Tim Churches (see his [blog post](https://timchurches.github.io/blog/posts/2020-03-18-modelling-the-effects-of-public-health-interventions-on-covid-19-transmission-part-2/)). The sirplus package was developed by
the Bioinformatics & Cellular Genomics team at St. Vincent's Institute of
Medical Research in order to help St. Vincents' Hospital model the COVID-19
pandemic.
The compartments available in this package include:
| E | Exposed **and** infected, not yet symptomatic but potentially infectious |
| I | Infected, symptomatic **and** infectious |
| Q | Infectious, but (self-)isolated |
| H | Requiring hospitalisation (would normally be hospitalised if capacity available) |
| R | Recovered, immune from further infection |
| F | Case fatality (death due to infection, not other causes) |
Again, for more information about these compartments and about the parameters
that are associated with them see Tim Churches's [blog post](https://timchurches.github.io/blog/posts/2020-03-18-modelling-the-effects-of-public-health-interventions-on-covid-19-transmission-part-2/).
```{r Load package}
#library(sirplus)
devtools::load_all(".")
```
## Simulate and inspect a baseline sirplus model
### Simulate
Here we will simulate the epidemiological data for a made-up population with 1000
susceptible individuals (S), 50 that are infected but not in the hospital or in
self-quarantine (I; maybe people that are infected/symptomatic but not tested/
aware), 10 confirmed cases that have self-isolated (Q), and 1 confirmed case that
has been hospitalized (H). We call this the baseline model because it uses
default parameters for disease spread (i.e. no additional interventions).
```{r simulate baselines}
s.num <- 2000 # number susceptible
i.num <- 15 # number infected
q.num <- 5 # number in self-isolation
h.num <- 1 # number in the hospital
nstep <- 90 # number of steps (e.g. days) to simulate
The sirplus model controls transitions between compartments, i.e. a change in state for an individual (e.g. going from self-isolation to hospital), using a variety of
transition parameters. You can use the `get_times()` and `plot_times()`
functions to examine the distributions of timings for various transitions based
on these parameters. In the case of a disease with observed data available, these plots can be used to sanity check parameter settings.
```{r baseline sims, fig.height=8}
plot_times(baseline_sim$sim)
```
### Plot baseline sirplus results
To visualise your sirplus model, you can plot the change in prevalence (i.e. people)
over time in each compartment.
```{r viz prevalence}
plot_models(sims = baseline_sim,
start_date = lubridate::ymd("2020-01-01"),
comp_remove = c('s.num', 'r.num'),
plot_title = 'Baseline Model')
```
## Run an experiment
With the sirplus package you can also set up experiments. We will set up two
experiments here:
- Experiment #1: One week after the beginning of the epidemic, schools and non-essential businesses are closed to encourage social distancing. This causes the act.rate to gradually drop from 10 to 6 over the course of the next week. In this experiment, we imagine these policies are never lifted, so act.rate remains at 6 for the duration of the simulation.
- Experiment #2: Again, one week after the beginning of the epidemic, social distancing policies are put into place resulting in act.rate dropping from 10 to 6 over the next week. But after two weeks these policies are lifted and the act.rate returns to normal within the next week.
From these results we see that this policy would likely reduce the peak number
of infections from 500 to 300 and would "flatten the curve" for infections and
thus hospitalizations (the peak in number of infected people is lower, but the number of people infected declines more slowly after the peak of the epidemic than in the baseline model).
## Visualize sirplus models to aid hospitals
Use the `get_weekly_local()` function to extract and plot the number of weekly expected
patients in a hospital. This function takes the following input:
- `sims`: Single or list of outputs from simulate.seiqhrf().
- `market.share`: Percent of cases in your model population (s.num) that are
anticipated at the hospital of interest. Default = 4% (0.04).
- `icu_percent`: Percent of hospitalised cases are are likely to need treatment in an intensive care unit (ICU). Default = 10% (0.1).
- `start_date`: Epidemic start date. Default is `NA`.
- `time_limit`: Number of days (nsteps) to include. Default = 90.
- `total_population`: True population size. This parameter is only needed if
the simulation size (s.num) was smaller than the true population size (i.e.