# Deterministic SIR model with varying act rate
param <- param.dcm(inf.prob = 0.2, act.rate = 1:10,
rec.rate = 1/3, a.rate = 0.011, ds.rate = 0.01,
di.rate = 0.03, dr.rate = 0.01)
init <- init.dcm(s.num = 1000, i.num = 1, r.num = 0)
control <- control.dcm(type = "SIR", nsteps = 100, dt = 0.25)
mod <- dcm(param, init, control)
# Plot disease prevalence by default
plot(mod)
# Plot prevalence of susceptibles
plot(mod, y = "s.num", popfrac = TRUE, col = "Greys")
# Plot number of susceptibles
plot(mod, y = "s.num", popfrac = FALSE, col = "Greys", grid = TRUE)
# Plot multiple runs of multiple compartments together
plot(mod, y = c("s.num", "i.num"),
run = 5, xlim = c(0, 50), grid = TRUE)
plot(mod, y = c("s.num", "i.num"),
run = 10, lty = 2, legend = "n", add = TRUE)
Run the code above in your browser using DataLab