get_sims {EpiModel} | R Documentation |
Extract Network Simulations
Description
Subsets the entire netsim
object to a subset of
simulations, essentially functioning like a reverse of
merge
.
Usage
get_sims(x, sims, var)
Arguments
x |
An object of class |
sims |
Either a numeric vector of simulation numbers to retain in the
output object, or |
var |
A character vector of variables to retain from |
Value
An updated object of class netsim
containing only the
simulations specified in sims
and the variables specified in
var
.
Examples
# Network model estimation
nw <- network_initialize(n = 100)
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)
init <- init.net(i.num = 10)
control <- control.net(type = "SI", nsteps = 10, nsims = 3, verbose.int = 0)
mod1 <- netsim(est1, param, init, control)
# Get sim 2
s.g2 <- get_sims(mod1, sims = 2)
# Get sims 2 and 3 and keep only a subset of variables
s.g2.small <- get_sims(mod1, sims = 2:3, var = c("i.num", "si.flow"))
# Extract the mean simulation for the variable i.num
sim.mean <- get_sims(mod1, sims = "mean", var = "i.num")
[Package EpiModel version 2.4.0 Index]