igraph (version 0.7.0)

sir: SIR model on graphs

Description

Run simulations for an SIR (susceptible-infected-recovered) model, on a graph

Usage

sir(graph, beta, gamma, no.sim=100)
## 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, ...)

Arguments

graph
The graph to run the model on. If directed, then edge directions are ignored and a warning is given.
beta
Non-negative scalar. The rate of infection of an individual that is susceptible and has a single infected neighbor. The infection rate of a susceptible individual with n infected neighbors is n times beta. Formally this is the rate paramet
gamma
Positive scalar. The rate of recovery of an infected individual. Formally, this is the rate parameter of an exponential distribution.
no.sim
Integer scalar, the number simulation runs to perform.
x
A sir object, returned by the sir function.
middle
Logical scalar, whether to return the middle of the time bins, or the boundaries.
na.rm
Logical scalar, whether to ignore NA values. sir objects do not contain any NA values currently, so this argument is effectively ignored.
comp
Character scalar. The component to calculate the quantile of. NI is infected agents, NS is susceptibles, NR stands for recovered.
prob
Numeric vector of probabilities, in [0,1], they specify the quantiles to calculate.
...
Additional arguments, ignored currently.

Value

  • For sir the results are returned in an object of class sir, which is a list, with one element for each simulation. Each simulation is itself a list with the following elements. They are all numeric vectors, with equal length:
    • times
    {The times of the events.}
  • NSThe number of susceptibles in the population, over time.
  • NIThe number of infected individuals in the population, over time.
  • NRThe number of recovered individuals in the population, over time.

concept

  • SIR model
  • Dynamics on graph

code

median

Details

The SIR model is a simple model from epidemiology. The individuals of the population might be in three states: susceptible, infected and recovered. Recovered people are assumed to be immune to the disease. Susceptibles become infected with a rate that depends on their number of infected neigbors. Infected people become recovered with a constant rate.

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.

References

Bailey, Norman T. J. (1975). The mathematical theory of infectious diseases and its applications (2nd ed.). London: Griffin.

See Also

plot.sir to conveniently plot the results

Examples

Run this code
g <- erdos.renyi.game(100, 100, type="gnm")
sm <- sir(g, beta=5, gamma=1)
plot(sm)

Run the code above in your browser using DataCamp Workspace