Skip to content
Snippets Groups Projects
Commit 7827e9b0 authored by Christina Azodi's avatar Christina Azodi
Browse files

added experiment back into vignette

parent 3bea66a2
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,7 @@
# produced vignettes
vignettes/*.html
vignettes/*.pdf
vignettes/sirplus-logo.png
# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3
.httr-oauth
# knitr and R markdown default cache directories
......
......@@ -158,7 +158,6 @@ plot_models <- function(sims = baseline_sim,
linetype = sim)) +
facet_grid(reo_exp(experiment) ~ .) +
geom_line(size = 1.5, alpha = 0.8) +
scale_linetype_manual(values = complines) +
scale_colour_manual(values = compcols, labels = complabels) +
labs(title = plot_title, x = x_axis, y = "Prevalence") +
theme_bw()
......
......@@ -40,19 +40,23 @@ that are associated with them see Tim Churches [blog post](https://timchurches.g
```{r Load package}
#library(sirplus)
devtools::load_all(".")
```
## Simulate baseline model
## Simulate and Inspect a Baseline sirplus Model
### Simulate
Here we will simulate the epi data for a made up population with 1000
susceptible individuals, 50 that are infected but not in the hospital or in
self-quarentine (maybe people that are infected/symptomatic but not tested/
aware), 10 confirmed cases that have self-isolated, and 1 confirmed case that
has been hospitalized.
has been hospitalized. We call this the baseline model because it uses
default parameters for disease spread (i.e. no additional interventions).
```{r simulate baselines}
s.num <- 1000 # number susceptible
s.num <- 2000 # number susceptible
i.num <- 50 # number infected
q.num <- 10 # number in self-isolation
h.num <- 1 # number in the hospital
......@@ -64,7 +68,7 @@ head(baseline_sim$df)
```
## Inspect Transition Distributions
### Inspect Baseline Transition Distributions
The sirplus model controls transitions between compartments using a variety of
transition parameters. You can use the `get_times()` and `plot_times()`
......@@ -73,17 +77,54 @@ on these parameters.
```{r baseline sims}
times <- get_times(baseline_sim)
plot(plot_times(times))
plot_times(times)
```
## Plot the SIR-plus results
### Plot Baseline sirplus Results
To visualise your sirplus model, plot the change in prevalence (i.e. people)
over time in each compartment.
```{r viz prevalence}
plot(plot_models(sims = baseline_sim,
time_lim = 50,
start_date = lubridate::ymd("2020-01-01"),
comp_remove = c('s.num', 'r.num'),
plot_title = 'Baseline Model'))
plot_models(sims = baseline_sim,
time_lim = 50,
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. For example, lets say
that one week after the beginning of the epidemic, schools and non-essential
buisnesses are closed to encourage social distancing. We can model the impact
that policy will have and compare it to our baseline by ramping down the
act.rate.e (# of exposure events, or acts, between individuals in the E and S
compartment, per day) after 7 days and plot this model next to our baseline.
```{r experiment 1}
closures_RampOnday7 <- function(t) {
ifelse(t < 7, 10, ifelse(t <= 14, 10 - (t-7)*(10 - 5)/7, 5))
}
closures_sim <- simulate.seiqhrf(s.num = s.num, i.num = i.num,
q.num = q.num, h.num = h.num,
act.rate.e = closures_RampOnday7(1:366),
act.rate.i = closures_RampOnday7(1:366))
plot_models(sims = c(baseline_sim, closures_sim),
sim_id = c('Baseline', 'Closures (d14)'),
time_lim = 50,
start_date = lubridate::ymd("2020-01-01"),
comp_remove = c('s.num', 'r.num'),
plot_title = 'Closures Experiment')
```
From these results we see that this policy would likey reduce the peak number
of infections from 700 to 500 and would flatten the curve for infections and
thus hospitalizations.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment