Epidemic Models (A Requested Special Topic…)

36-462/662, Spring 2020

16 April 2020 (small revisions, 20 April 2020)

Simple Epidemic Models

Stochastic Form of the SIR Model (1)

Stochastic Form of the SIR Model (2)

SIR is easy to simulate

sim.SIR <- function(n, beta, gamma, s.initial=n-1, i.initial=1, r.initial=0, T) {
    stopifnot(s.initial+i.initial+r.initial == n)
    states <- matrix(NA, nrow=3, ncol=T)
    rownames(states) <- c("S", "I", "R")
    states[,1] <- c(s.initial, i.initial, r.initial)
    for (t in 2:T) {
        contagions <- rbinom(n=1, size=states["S",t-1],
        removals <- rbinom(n=1, size=states["I",t-1],
        states["S",t] <- states["S",t-1] - contagions
        states["I",t] <- states["I",t-1] + contagions - removals
        states["R",t] <- states["R",t-1] + removals

What One Simulation Looks Like

Multiple Simulations with the Same Settings

What If We Make Contagion Harder?


Maybe Not Quite That Much Harder?

Go Back to the Original Ease of Contagion, But Make Removal Faster