The Kermack-McKendrick SIR model (Brown, Rothery, et al. 1993) is defined as

```
dS/dt = -beta*N*S
dI/dt = beta*N*S - gamma*I
dR/dt = gamma*I
```

Note that simulations of this model can generate in all zero propensity, if the first reaction is a recovery of the single ‘Infected’ individual.

Define parameters

```
library(GillespieSSA2)
<- "Kermack-McKendrick SIR model"
sim_name <- c(beta = .001, gamma = .1)
params <- 100
final_time <- c(S = 500, I = 1, R = 0) initial_state
```

Define reactions

```
<- list(
reactions reaction("beta * S * I", c(S = -1, I = +1), name = "transmission"),
reaction("gamma * I", c(I = -1, R = +1), name = "recovery")
)
```

Run simulations with the Exact method

```
set.seed(1)
<- ssa(
out initial_state = initial_state,
reactions = reactions,
params = params,
final_time = final_time,
method = ssa_exact(),
sim_name = sim_name
) plot_ssa(out)
```

Run simulations with the Explict tau-leap method

```
set.seed(1)
<- ssa(
out initial_state = initial_state,
reactions = reactions,
params = params,
final_time = final_time,
method = ssa_etl(),
sim_name = sim_name
) plot_ssa(out)
```

Run simulations with the Binomial tau-leap method

```
set.seed(2)
<- ssa(
out initial_state = initial_state,
reactions = reactions,
params = params,
final_time = final_time,
method = ssa_btl(),
sim_name = sim_name
) plot_ssa(out)
```

Brown, David, Peter Rothery, et al. 1993. *Models in Biology: Mathematics, Statistics and Computing.* John Wiley & Sons Ltd.