This function can conveniently plot the results of multiple SIR model simulations.
# S3 method for sir
plot(
x,
comp = c("NI", "NS", "NR"),
median = TRUE,
quantiles = c(0.1, 0.9),
color = NULL,
median_color = NULL,
quantile_color = NULL,
lwd.median = 2,
lwd.quantile = 2,
lty.quantile = 3,
xlim = NULL,
ylim = NULL,
xlab = "Time",
ylab = NULL,
...
)
The output of the SIR simulation, coming from the sir
function.
Character scalar, which component to plot. Either ‘NI’ (infected, default), ‘NS’ (susceptible) or ‘NR’ (recovered).
Logical scalar, whether to plot the (binned) median.
A vector of (binned) quantiles to plot.
Color of the individual simulation curves.
Color of the median curve.
Color(s) of the quantile curves. (It is recycled if needed and non-needed entries are ignored if too long.)
Line width of the median.
Line width of the quantile curves.
Line type of the quantile curves.
The x limits, a two-element numeric vector. If NULL
, then
it is calculated from the data.
The y limits, a two-element numeric vector. If NULL
, then
it is calculated from the data.
The x label.
The y label. If NULL
then it is automatically added based
on the comp
argument.
Additional arguments are passed to plot
, that is run
before any of the curves are added, to create the figure.
Nothing.
The number of susceptible/infected/recovered individuals is plotted over time, for multiple simulations.
Bailey, Norman T. J. (1975). The mathematical theory of infectious diseases and its applications (2nd ed.). London: Griffin.
sir
for running the actual simulation.
# NOT RUN {
g <- sample_gnm(100, 100)
sm <- sir(g, beta=5, gamma=1)
plot(sm)
# }
Run the code above in your browser using DataLab