plot,SimInf_model-method | R Documentation |
Plot either the median and the quantile range of the counts in all nodes, or plot the counts in specified nodes.
## S4 method for signature 'SimInf_model'
plot(
x,
y,
level = 1,
index = NULL,
range = 0.5,
type = "s",
lwd = 2,
frame.plot = FALSE,
legend = TRUE,
...
)
x |
The |
y |
Character vector or formula with the compartments in the
model to include in the plot. Default includes all
compartments in the model. Can also be a formula that
specifies the compartments that define the cases with a
disease or that have a specific characteristic (numerator),
and the compartments that define the entire population of
interest (denominator). The left-hand-side of the formula
defines the cases, and the right-hand-side defines the
population, for example, |
level |
The level at which the prevalence is calculated at
each time point in |
index |
Indices specifying the nodes to include when plotting
data. Plot one line for each node. Default ( |
range |
Show the quantile range of the count in each
compartment. Default is to show the interquartile range
i.e. the middle 50% of the count in transparent color. The
median value is shown in the same color. Use |
type |
The type of plot to draw. The default |
lwd |
The line width. Default is |
frame.plot |
a logical indicating whether a box should be drawn around the plot. |
legend |
a logical indicating whether a legend for the compartments should be added to the plot. A legend is not drawn for a prevalence plot. |
... |
Other graphical parameters that are passed on to the plot function. |
## Not run:
## For reproducibility, call the set.seed() function and specify
## the number of threads to use. To use all available threads,
## remove the set_num_threads() call.
set.seed(123)
set_num_threads(1)
## Create an 'SIR' model with 100 nodes and initialise
## it with 990 susceptible individuals and 10 infected
## individuals in each node. Run the model over 100 days.
model <- SIR(u0 = data.frame(S = rep(990, 100),
I = rep(10, 100),
R = rep(0, 100)),
tspan = 1:100,
beta = 0.16,
gamma = 0.077)
## Run the model and save the result.
result <- run(model)
## Plot the median and interquartile range of the number
## of susceptible, infected and recovered individuals.
plot(result)
## Plot the median and the middle 95\
## number of susceptible, infected and recovered individuals.
plot(result, range = 0.95)
## Plot the median and interquartile range of the number
## of infected individuals.
plot(result, "I")
## Use the formula notation instead to plot the median and
## interquartile range of the number of infected individuals.
plot(result, ~I)
## Plot the number of susceptible, infected
## and recovered individuals in the first
## three nodes.
plot(result, index = 1:3, range = FALSE)
## Use plot type line instead.
plot(result, index = 1:3, range = FALSE, type = "l")
## Plot the number of infected individuals in the first node.
plot(result, "I", index = 1, range = FALSE)
## Plot the proportion of infected individuals (cases)
## in the population.
plot(result, I ~ S + I + R)
## Plot the proportion of nodes with infected individuals.
plot(result, I ~ S + I + R, level = 2)
## Plot the median and interquartile range of the proportion
## of infected individuals in each node
plot(result, I ~ S + I + R, level = 3)
## Plot the proportion of infected individuals in the first
## three nodes.
plot(result, I ~ S + I + R, level = 3, index = 1:3, range = FALSE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.