Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
sirplus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BioCellGen-public
sirplus
Commits
7827e9b0
Commit
7827e9b0
authored
5 years ago
by
Christina Azodi
Browse files
Options
Downloads
Patches
Plain Diff
added experiment back into vignette
parent
3bea66a2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
R/results-parse.R
+0
-1
0 additions, 1 deletion
R/results-parse.R
vignettes/sirplus_intro.Rmd
+52
-11
52 additions, 11 deletions
vignettes/sirplus_intro.Rmd
with
53 additions
and
12 deletions
.gitignore
+
1
−
0
View file @
7827e9b0
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
R/results-parse.R
+
0
−
1
View file @
7827e9b0
...
...
@@ -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
()
...
...
This diff is collapsed.
Click to expand it.
vignettes/sirplus_intro.Rmd
+
52
−
11
View file @
7827e9b0
...
...
@@ -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 <-
1
000 # number susceptible
s.num <-
2
000 # 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.
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment