# NOT RUN {
## Define the Kermack-McKendrick SIR model and run once using the Direct method
parms <- c(beta=.001, gamma=.100)
x0 <- c(S=500, I=1, R=0) # Initial state vector
nu <- matrix(c(-1,0,1,-1,0,1),nrow=3,byrow=TRUE) # State-change matrix
a <- c("beta*S*I", "gamma*I") # Propensity vector
tf <- 100 # Final time
simName <- "Kermack-McKendrick SIR"
out <- ssa(x0,a,nu,parms,tf,method="D",simName,verbose=TRUE,consoleInterval=1)
## Basic ssa plot
ssa.plot(out)
# Plot only the infectious class
ssa.plot(out,plot.from=3,plot.to=3)
# }
Run the code above in your browser using DataLab