## S3 method for class 'sir':
time_bins(x, middle = TRUE)## S3 method for class 'sir':
median(x, na.rm = FALSE)
## S3 method for class 'sir':
quantile(x, comp = c("NI", "NS", "NR"), prob, ...)
sir(graph, beta, gamma, no.sim = 100)
sir
object, returned by the sir
function.NA
values. sir
objects do not contain any NA
values currently, so this argument is
effectively ignored.NI
is infected agents, NS
is susceptibles, NR
stands
for recovered.sir
the results are returned in an object of class
sir
Function time_bins
returns a numeric vector, the middle or the
boundaries of the time bins, depending on the middle
argument.
median
returns a list of three named numeric vectors, NS
,
NI
and NR
. The names within the vectors are created from the
time bins.
quantile
returns the same vector as median
(but only one, the
one requested) if only one quantile is requested. If multiple quantiles are
requested, then a list of these vectors is returned, one for each quantile.
The function sir
simulates the model.
Function time_bins
bins the simulation steps, using the
Freedman-Diaconis heuristics to determine the bin width.
Function median
and quantile
calculate the median and
quantiles of the results, respectively, in bins calculated with
time_bins
.
plot.sir
to conveniently plot the resultsg <- sample_gnm(100, 100)
sm <- sir(g, beta=5, gamma=1)
plot(sm)
Run the code above in your browser using DataCamp Workspace