forked from bristolmathmodellers/biddmodellingcourse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_model.Rd
66 lines (50 loc) · 1.8 KB
/
plot_model.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot_model.R
\name{plot_model}
\alias{plot_model}
\title{Plot Compartment Populations over Time for a Model Simulation}
\usage{
plot_model(sim, prev_sim = NULL, model_labels = NULL, facet = TRUE,
interactive = FALSE)
}
\arguments{
\item{sim}{A tibble of model output as formated by \code{\link[biddmodellingcourse]{solve_ode}}}
\item{prev_sim}{A second tibble of model output formated as for \code{sim}. Used to compare to model runs.}
\item{model_labels}{A character vector of model names, defaults to \code{c("Current", "Previous")}.}
\item{facet}{Logical, defaults to \code{TRUE}. If \code{FALSE} then the plot will not be facetted
otherwise it will be.}
\item{interactive}{Logical, defaults to \code{FALSE}. If \code{TRUE} produces an interative plot.}
}
\value{
A Plot of each model compartments population over time.
}
\description{
Make seperate plots for each model compartment. Assumes model output is structured
as that produced from \code{\link[biddmodellingcourse]{solve_ode}}.
}
\examples{
## Intialise
N = 100000
I_0 = 1
S_0 = N - I_0
R_0 = 1.1
beta = R_0
##Time for model to run over
tbegin = 0
tend = 50
times <- seq(tbegin, tend, 1)
##Vectorise input
parameters <- as.matrix(c(beta = beta))
inits <- as.matrix(c(S = S_0, I = I_0))
sim <- solve_ode(model = SI_ode, inits, parameters, times, as.data.frame = TRUE)
plot_model(sim, facet = FALSE, interactive = FALSE)
plot_model(sim, facet = TRUE, interactive = FALSE)
## Compare with an updated model run
#'## Intialise
R_0 = 1.3
beta = R_0
parameters <- as.matrix(c(beta = beta))
new_sim <- solve_ode(model = SI_ode, inits, parameters, times, as.data.frame = TRUE)
plot_model(new_sim,sim, facet = FALSE, interactive = FALSE)
plot_model(new_sim, sim, facet = TRUE, interactive = FALSE)
}