make_networkDynamic: Build a networkDynamic Object from Simulation Output

View source: R/network.R

make_networkDynamicR Documentation

Build a networkDynamic Object from Simulation Output

Description

Reconstructs a networkDynamic object from a completed netsim simulation, using the cumulative edgelist for edge spells and the tracked attribute history for vertex activity and time-varying attributes. The resulting object can be used with ndtv for visualization or with tsna for temporal network analysis.

Usage

make_networkDynamic(sim, sim_num = 1, network = NULL)

Arguments

sim

An EpiModel object of class netsim.

sim_num

The simulation number to use (default 1).

network

Optional network number to filter edges. If NULL (default), edges from all networks are included.

Details

The simulation must be run with cumulative.edgelist = TRUE, save.cumulative.edgelist = TRUE, and truncate.el.cuml = Inf in control.net, so that the cumulative edgelist holds every edge, and with at least one attribute in tracked.attributes or tracked.attributes.once, so that the activity of the nodes is recorded. The vertex ids of the networkDynamic object are the unique_ids of the nodes. Each pair of nodes tied on a layer has one edge, with one activity spell per period the tie was active, and the layer in the network edge attribute. With network = NULL and more than one layer, the layers are merged into one network that allows multiple edges (multiple = TRUE), so that a pair of nodes tied on two layers has one edge per layer.

The nodes are active from the first record of the attribute history: for a new simulation from time 0, as in the networkDynamic objects that netsim() saves without tergmLite, and for a restarted one from start - 1, the snapshot its history starts from. An edge that formed before the activity spell of one of its nodes starts is active from the start of that spell, so that no edge is active between inactive vertices.

Value

A networkDynamic object with active vertex spells and time-varying vertex attributes.

See Also

get_attr_at(), get_attr_history()

Examples


nw <- network_initialize(n = 100)
est <- netest(nw, formation = ~edges, target.stats = 50,
              coef.diss = dissolution_coefs(~offset(edges), 10),
              verbose = FALSE)
control <- control.net(type = "SI", nsteps = 20, nsims = 1,
                       tergmLite = TRUE, resimulate.network = TRUE,
                       cumulative.edgelist = TRUE,
                       save.cumulative.edgelist = TRUE,
                       truncate.el.cuml = Inf,
                       tracked.attributes = "status", verbose = FALSE)
sim <- netsim(est, param.net(inf.prob = 0.3, act.rate = 1),
              init.net(i.num = 10), control)

# The full network history of a tergmLite run, with each node's status
nd <- make_networkDynamic(sim)
nd
x10 <- network.collapse(nd, at = 10)
table(get_vertex_attribute(x10, "status"))


EpiModel documentation built on Oct. 16, 2026, 5:07 p.m.