merge.netsim | R Documentation |
Merges epidemiological data from two independent simulations of
stochastic network models from netsim
.
## S3 method for class 'netsim'
merge(
x,
y,
keep.transmat = TRUE,
keep.network = TRUE,
keep.nwstats = TRUE,
keep.other = TRUE,
param.error = TRUE,
keep.diss.stats = TRUE,
...
)
x |
An |
y |
Another |
keep.transmat |
If |
keep.network |
If |
keep.nwstats |
If |
keep.other |
If |
param.error |
If |
keep.diss.stats |
If |
... |
Additional merge arguments (not currently used). |
This merge function combines the results of two independent simulations of
netsim
class models, simulated under separate function calls.
The model parameterization between the two calls must be exactly the same,
except for the number of simulations in each call. This allows for manual
parallelization of model simulations.
This merge function does not work the same as the default merge, which allows for a combined object where the structure differs between the input elements. Instead, the function checks that objects are identical in model parameterization in every respect (except number of simulations) and binds the results.
An EpiModel
object of class netsim
containing
the data from both x
and y
.
# Network model
nw <- network_initialize(n = 100)
coef.diss <- dissolution_coefs(dissolution = ~offset(edges), duration = 10)
est <- netest(nw, formation = ~edges, target.stats = 25,
coef.diss = coef.diss, verbose = FALSE)
# Epidemic models
param <- param.net(inf.prob = 1)
init <- init.net(i.num = 1)
control <- control.net(type = "SI", nsteps = 20, nsims = 2,
save.nwstats = TRUE,
nwstats.formula = ~edges + degree(0),
verbose = FALSE)
x <- netsim(est, param, init, control)
y <- netsim(est, param, init, control)
# Merging
z <- merge(x, y)
# Examine separate and merged data
as.data.frame(x)
as.data.frame(y)
as.data.frame(z)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.