
Last chance! 50% off unlimited learning
Sale ends in
Extracts the networkDynamic
object from a either a
network epidemic model object generated with netsim
or a
network diagnostic simulation generated with netdx
, with
the option to collapse the extracted networkDynamic
object down to a static network
object.
get_network(
x,
sim = 1,
network = 1,
collapse = FALSE,
at,
ergm.create.nd = TRUE
)
An EpiModel
object of class netsim
or
netdx
.
Simulation number of extracted network.
Network number, for netsim
objects with multiple
overlapping networks (advanced use, and not applicable to netdx
objects).
If TRUE
, collapse the networkDynamic
object to
a static network
object at a specified time step.
If collapse
is TRUE
, the time step at which the
extracted network should be collapsed.
If TRUE
and x
contains a static ERGM
(i.e., a netest model with duration = 1), then create a
networkDynamic
object from the stored list of static
network
objects; if FALSE
, output the network list
directly.
This function requires that the networkDynamic
is saved during the
network simulation while running either netsim
or
netdx
. For the former, that is specified with the
tergmLite
parameter in control.net
set to FALSE
.
For the latter, that is specified with the keep.tedgelist
parameter
directly in netdx
.
# Set up network and TERGM formiula
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)
# Estimate the model
est <- netest(nw, formation, target.stats, coef.diss)
# Run diagnostics, saving the networkDynamic objects
dx <- netdx(est, nsteps = 10, nsims = 3, keep.tnetwork = TRUE,
verbose = FALSE)
# Extract the network for simulation 2 from dx object
get_network(dx, sim = 2)
# Extract and collapse the network from simulation 1 at time step 5
get_network(dx, collapse = TRUE, at = 5)
# Parameterize the epidemic model, and simulate it
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 = 10, nsims = 3, verbose = FALSE)
mod <- netsim(est, param, init, control)
# Extract the network for simulation 2 from mod object
get_network(mod, sim = 2)
## Extract and collapse the network from simulation 1 at time step 5
get_network(mod, collapse = TRUE, at = 5)
Run the code above in your browser using DataLab