netsim | R Documentation |
Simulates stochastic network epidemic models for infectious disease.
netsim(x, param, init, control)
x |
If |
param |
Model parameters, as an object of class |
init |
Initial conditions, as an object of class |
control |
Control settings, as an object of class
|
Stochastic network models explicitly represent phenomena within and across edges (pairs of nodes that remain connected) over time. This enables edges to have duration, allowing for repeated transmission-related acts within the same dyad, specification of edge formation and dissolution rates, control over the temporal sequencing of multiple edges, and specification of network-level features. A detailed description of these models, along with examples, is found in the Network Modeling for Epidemics course materials.
The netsim
function performs modeling of both the base model types
and original models. Base model types include one-group and two-group models
with disease types for Susceptible-Infected (SI), Susceptible-Infected-Recovered (SIR),
and Susceptible-Infected-Susceptible (SIS).
Original models may be parameterized by writing new process modules that
either take the place of existing modules (for example, disease recovery), or
supplement the set of existing processes with a new one contained in a new
module. This functionality is documented in the
Extending EpiModel
section of the Network Modeling for Epidemics
course materials. The list of modules within netsim
available for
modification is listed in modules.net
.
A list of class netsim
with the following elements:
param: the epidemic parameters passed into the model through
param
, with additional parameters added as necessary.
control: the control settings passed into the model through
control
, with additional controls added as necessary.
epi: a list of data frames, one for each epidemiological output from the model. Outputs for base models always include the size of each compartment, as well as flows in, out of, and between compartments.
stats: a list containing two sublists, nwstats
for any
network statistics saved in the simulation, and transmat
for
the transmission matrix saved in the simulation. See
control.net
for further
details.
network: a list of lists of networkDynamic
or
networkLite
objects, with one list of objects for each model
simulation.
If control$raw.output == TRUE
: A list of the raw (pre-processed)
netsim_dat
objects, for use in simulation continuation.
Jenness SM, Goodreau SM and Morris M. EpiModel: An R Package for Mathematical Modeling of Infectious Disease over Networks. Journal of Statistical Software. 2018; 84(8): 1-47.
Extract the model results with as.data.frame.netsim
.
Summarize the time-specific model results with
summary.netsim
. Plot the model results with
plot.netsim
.
## Not run:
## Example 1: SI Model without Network Feedback
# Network model estimation
nw <- network_initialize(n = 100)
nw <- set_vertex_attribute(nw, "group", rep(1:2, each = 50))
formation <- ~edges
target.stats <- 50
coef.diss <- dissolution_coefs(dissolution = ~offset(edges), duration = 20)
est1 <- netest(nw, formation, target.stats, coef.diss, verbose = FALSE)
# Epidemic model
param <- param.net(inf.prob = 0.3, inf.prob.g2 = 0.15)
init <- init.net(i.num = 10, i.num.g2 = 10)
control <- control.net(type = "SI", nsteps = 100, nsims = 5, verbose.int = 0)
mod1 <- netsim(est1, param, init, control)
# Print, plot, and summarize the results
mod1
plot(mod1)
summary(mod1, at = 50)
## Example 2: SIR Model with Network Feedback
# Recalculate dissolution coefficient with departure rate
coef.diss <- dissolution_coefs(dissolution = ~offset(edges), duration = 20,
d.rate = 0.0021)
# Reestimate the model with new coefficient
est2 <- netest(nw, formation, target.stats, coef.diss)
# Reset parameters to include demographic rates
param <- param.net(inf.prob = 0.3, inf.prob.g2 = 0.15,
rec.rate = 0.02, rec.rate.g2 = 0.02,
a.rate = 0.002, a.rate.g2 = NA,
ds.rate = 0.001, ds.rate.g2 = 0.001,
di.rate = 0.001, di.rate.g2 = 0.001,
dr.rate = 0.001, dr.rate.g2 = 0.001)
init <- init.net(i.num = 10, i.num.g2 = 10,
r.num = 0, r.num.g2 = 0)
control <- control.net(type = "SIR", nsteps = 100, nsims = 5,
resimulate.network = TRUE, tergmLite = TRUE)
# Simulate the model with new network fit
mod2 <- netsim(est2, param, init, control)
# Print, plot, and summarize the results
mod2
plot(mod2)
summary(mod2, at = 40)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.