EVOLUTION-MANAGER
Edit File: sir.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: SIR model on graphs</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for time_bins.sir {igraph}"><tr><td>time_bins.sir {igraph}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>SIR model on graphs</h2> <h3>Description</h3> <p>Run simulations for an SIR (susceptible-infected-recovered) model, on a graph </p> <h3>Usage</h3> <pre> ## 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) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>A <code>sir</code> object, returned by the <code>sir</code> function.</p> </td></tr> <tr valign="top"><td><code>middle</code></td> <td> <p>Logical scalar, whether to return the middle of the time bins, or the boundaries.</p> </td></tr> <tr valign="top"><td><code>na.rm</code></td> <td> <p>Logical scalar, whether to ignore <code>NA</code> values. <code>sir</code> objects do not contain any <code>NA</code> values currently, so this argument is effectively ignored.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Additional arguments, ignored currently.</p> </td></tr> <tr valign="top"><td><code>comp</code></td> <td> <p>Character scalar. The component to calculate the quantile of. <code>NI</code> is infected agents, <code>NS</code> is susceptibles, <code>NR</code> stands for recovered.</p> </td></tr> <tr valign="top"><td><code>prob</code></td> <td> <p>Numeric vector of probabilities, in [0,1], they specify the quantiles to calculate.</p> </td></tr> <tr valign="top"><td><code>graph</code></td> <td> <p>The graph to run the model on. If directed, then edge directions are ignored and a warning is given.</p> </td></tr> <tr valign="top"><td><code>beta</code></td> <td> <p>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 parameter of an exponential distribution.</p> </td></tr> <tr valign="top"><td><code>gamma</code></td> <td> <p>Positive scalar. The rate of recovery of an infected individual. Formally, this is the rate parameter of an exponential distribution.</p> </td></tr> <tr valign="top"><td><code>no.sim</code></td> <td> <p>Integer scalar, the number simulation runs to perform.</p> </td></tr> </table> <h3>Details</h3> <p>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 neighbors. Infected people become recovered with a constant rate. </p> <p>The function <code>sir</code> simulates the model. </p> <p>Function <code>time_bins</code> bins the simulation steps, using the Freedman-Diaconis heuristics to determine the bin width. </p> <p>Function <code>median</code> and <code>quantile</code> calculate the median and quantiles of the results, respectively, in bins calculated with <code>time_bins</code>. </p> <h3>Value</h3> <p>For <code>sir</code> the results are returned in an object of class ‘<code>sir</code>’, 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: </p> <dl> <dt>times</dt><dd><p>The times of the events.</p> </dd> <dt>NS</dt><dd><p>The number of susceptibles in the population, over time.</p> </dd> <dt>NI</dt><dd><p>The number of infected individuals in the population, over time.</p> </dd> <dt>NR</dt><dd><p>The number of recovered individuals in the population, over time.</p> </dd> </dl> <p>Function <code>time_bins</code> returns a numeric vector, the middle or the boundaries of the time bins, depending on the <code>middle</code> argument. </p> <p><code>median</code> returns a list of three named numeric vectors, <code>NS</code>, <code>NI</code> and <code>NR</code>. The names within the vectors are created from the time bins. </p> <p><code>quantile</code> returns the same vector as <code>median</code> (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. </p> <h3>Author(s)</h3> <p>Gabor Csardi <a href="mailto:csardi.gabor@gmail.com">csardi.gabor@gmail.com</a>. Eric Kolaczyk (<a href="http://math.bu.edu/people/kolaczyk/">http://math.bu.edu/people/kolaczyk/</a>) wrote the initial version in R. </p> <h3>References</h3> <p>Bailey, Norman T. J. (1975). The mathematical theory of infectious diseases and its applications (2nd ed.). London: Griffin. </p> <h3>See Also</h3> <p><code><a href="plot.sir.html">plot.sir</a></code> to conveniently plot the results </p> <h3>Examples</h3> <pre> g <- sample_gnm(100, 100) sm <- sir(g, beta=5, gamma=1) plot(sm) </pre> <hr /><div style="text-align: center;">[Package <em>igraph</em> version 1.3.5 <a href="00Index.html">Index</a>]</div> </body></html>