## See the EpiModel Tutorial vignette for more details and examples ##
## Independent SI Model ##
# Initialize network and set network model parameters
nw <- network.initialize(n=500, bipartite=250, directed=FALSE)
formation <- ~ edges + b1degree(0:1) + b2degree(0:1)
target.stats <- c(165, 100, 137.5, 120, 102.5)
dissolution <- ~ offset(edges)
coef.diss <- dissolution.coefs(dissolution, duration=25)
# Estimate the ERGM models (see help for epiNet.est)
# Skipping model diagnostics for this, but should always run
est1 <- epiNet.est(
nw,
formation,
dissolution,
target.stats,
coef.diss)
# Simulate 10 networks from model fit (see help for epiNet.simNet)
# Skipping model diagnostics for this, but should always run
nwsims <- epiNet.simNet(est1, nsteps = 250, nsims = 10)
# Independent epidemic model simulation for SI disease
# Transmissibility is higher to mode 1 than mode 2
sim.SI <- epiNet.simTrans(
nwsims,
type = "SI",
vital = FALSE,
trans.rate = 0.3,
trans.rate.m2 = 0.15,
i.num = 50,
sims.per.nw = 1)
# Print, plot, and summarize the results
sim.SI
plot(sim.SI, type="sim")
plot(sim.SI, y=c("i.num", "i.num.m2"), sim.lines=TRUE,
sim.col=c("steelblue", "firebrick"), qnts=0.5)
plot(sim.SI, type="network", at=50, col.inf=TRUE, shp.bip="square")
summary(sim.SI, time=50)
## Dependent SIR Model ##
coef.diss <- dissolution.coefs(dissolution, duration=25, d.rate=0.0021)
est2 <- epiNet.est(
nw,
formation,
dissolution,
target.stats,
coef.diss)
sim.SIR <- epiNet.simTrans(
est2,
type = "SIR",
vital = TRUE,
i.num = 50,
trans.rate = 0.3,
trans.rate.m2 = 0.15,
rec.rate = 0.02,
b.rate = 0.0021*2,
ds.rate = 0.0021,
di.rate = 0.0021*1.1,
dr.rate = 0.0021,
nsteps = 250,
sims.per.nw = 10)
# Print, plot, and summarize the results
sim.SIR
plot(sim.SIR, type="sim")
plot(sim.SIR, type="network")
summary(sim.SIR, time=100)
Run the code above in your browser using DataLab