# Initializing SIR model with agents_smallworld
sir <- ModelSIR(name = "COVID-19", prevalence = 0.01, transmission_rate = 0.9,
recovery_rate = 0.1)
agents_smallworld(
sir,
n = 1000,
k = 5,
d = FALSE,
p = .01
)
run(sir, ndays = 100, seed = 1912)
sir
# We can also retrieve the network
net <- get_network(sir)
head(net)
# Simulating a bernoulli graph
set.seed(333)
n <- 1000
g <- matrix(runif(n^2) < .01, nrow = n)
diag(g) <- FALSE
el <- which(g, arr.ind = TRUE) - 1L
# Generating an empty model
sir <- ModelSIR("COVID-19", .01, .8, .3)
agents_from_edgelist(
sir,
source = el[, 1],
target = el[, 2],
size = n,
directed = TRUE
)
# Running the simulation
run(sir, 50)
plot(sir)
Run the code above in your browser using DataLab