## For reproducibility, specify the number of threads.
set_num_threads(1)
## Create an 'SIR' model with 100 nodes.
model <- SIR(u0 = data.frame(S = rep(990, 100),
I = rep(10, 100),
R = rep(0, 100)),
tspan = 1:100,
beta = 0.16,
gamma = 0.077)
## Run the model with a fixed seed for reproducibility.
result <- run(model, seed = 22)
## Plot counts (median and IQR)
plot(result)
## Plot individual trajectories for specific nodes
plot(result, index = 1:3, range = FALSE)
## Plot prevalence (proportion of infected)
plot(result, I ~ S + I + R)
## Customize labels
plot(result, "I", xlab = "Time", ylab = "Count", main = "Infections")
Run the code above in your browser using DataLab