get_nwstats | R Documentation |
Extracts network statistics from a network epidemic model
simulated with netsim
or a network diagnostics object
simulated with netdx
. Statistics can be returned either
as a single data frame or as a list of matrices (one matrix
for each simulation).
get_nwstats(x, sim, network = 1, mode = c("data.frame", "list"))
x |
An |
sim |
A vector of simulation numbers from the extracted object. |
network |
Network number, for |
mode |
Either |
A data frame or list of matrices containing the network statistics.
# Two-group Bernoulli random graph TERGM
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)
est <- netest(nw, formation, target.stats, coef.diss, verbose = FALSE)
dx <- netdx(est, nsim = 3, nsteps = 10, verbose = FALSE,
nwstats.formula = ~edges + isolates)
get_nwstats(dx)
get_nwstats(dx, sim = 1)
# SI 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 = 10, nsims = 3,
nwstats.formula = ~edges + meandeg + degree(0:5),
verbose = FALSE)
mod <- netsim(est, param, init, control)
# Extract the network statistics from all or sets of simulations
get_nwstats(mod)
get_nwstats(mod, sim = 2)
get_nwstats(mod, sim = c(1, 3))
# On the fly summary stats
summary(get_nwstats(mod))
colMeans(get_nwstats(mod))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.