control.net {EpiModel} | R Documentation |
Control Settings for Stochastic Network Models
Description
Sets the controls for stochastic network models simulated with
netsim
.
Usage
control.net(
type,
nsteps,
start = 1,
nsims = 1,
ncores = 1,
resimulate.network = FALSE,
tergmLite = FALSE,
cumulative.edgelist = FALSE,
truncate.el.cuml = 0,
attr.rules,
epi.by,
initialize.FUN = initialize.net,
resim_nets.FUN = resim_nets,
summary_nets.FUN = summary_nets,
infection.FUN = NULL,
recovery.FUN = NULL,
departures.FUN = NULL,
arrivals.FUN = NULL,
nwupdate.FUN = nwupdate.net,
prevalence.FUN = prevalence.net,
verbose.FUN = verbose.net,
module.order = NULL,
save.nwstats = TRUE,
nwstats.formula = "formation",
save.transmat = TRUE,
save.network,
save.other,
verbose = TRUE,
verbose.int = 1,
skip.check = FALSE,
raw.output = FALSE,
tergmLite.track.duration = FALSE,
set.control.ergm = control.simulate.formula(MCMC.burnin = 2e+05),
set.control.tergm = control.simulate.formula.tergm(),
save.diss.stats = TRUE,
dat.updates = NULL,
...
)
Arguments
type |
Disease type to be modeled, with the choice of |
nsteps |
Number of time steps to simulate the model over. This must be a positive integer
that is equal to the final step of a simulation. If a simulation is restarted with |
start |
For models with network resimulation, time point to start up the simulation. For
restarted simulations, this must be one greater than the final time step in the prior
simulation and must be less than the value in |
nsims |
The total number of disease simulations. |
ncores |
Number of processor cores to run multiple simulations on, using the |
resimulate.network |
If |
tergmLite |
Logical indicating usage of either |
cumulative.edgelist |
If |
truncate.el.cuml |
Number of time steps of the cumulative edgelist to retain. See help for
|
attr.rules |
A list containing the rules for setting the attributes of incoming nodes, with one list element per attribute to be set (see details below). |
epi.by |
A character vector of length 1 containing a nodal attribute for which subgroup stratified prevalence summary statistics are calculated. This nodal attribute must be contained in the network model formation formula, otherwise it is ignored. |
initialize.FUN |
Module to initialize the model at time 1, with the default function of
|
resim_nets.FUN |
Module to resimulate the network at each time step, with the default
function of |
summary_nets.FUN |
Module to extract summary statistics of the network
at each time step, with the default function of |
infection.FUN |
Module to simulate disease infection, with the default function of
|
recovery.FUN |
Module to simulate disease recovery, with the default function of
|
departures.FUN |
Module to simulate departure or exit, with the default function of
|
arrivals.FUN |
Module to simulate arrivals or entries, with the default function of
|
nwupdate.FUN |
Module to handle updating of network structure and nodal attributes due to
exogenous epidemic model processes, with the default function of |
prevalence.FUN |
Module to calculate disease prevalence at each time step, with the default
function of |
verbose.FUN |
Module to print simulation progress to screen, with the default function of
|
module.order |
A character vector of module names that lists modules in the order in which
they should be evaluated within each time step. If |
save.nwstats |
If |
nwstats.formula |
A right-hand sided ERGM formula that includes network statistics of
interest, with the default to the formation formula terms. Supports |
save.transmat |
If |
save.network |
If |
save.other |
A character vector of elements on the |
verbose |
If |
verbose.int |
Time step interval for printing progress to console, where |
skip.check |
If |
raw.output |
If |
tergmLite.track.duration |
If |
set.control.ergm |
Control arguments passed to |
set.control.tergm |
Control arguments passed to |
save.diss.stats |
If |
dat.updates |
Either |
... |
Additional control settings passed to model. |
Details
control.net
sets the required control settings for any network model solved with the netsim
function. Controls are required for both base model types and when passing original process
modules. For an overview of control settings for base models, consult the
Basic Network Models tutorials. For all base models, the
type
argument is a necessary parameter and it has no default.
Value
An EpiModel object of class control.net
.
The attr.rules Argument
The attr.rules
parameter is used to specify the rules for how nodal attribute values for
incoming nodes should be set. These rules are only necessary for models in which there are
incoming nodes (i.e., arrivals). There are three rules available for each attribute value:
-
current
: new nodes will be assigned this attribute in proportion to the distribution of that attribute among existing nodes at that current time step. -
t1
: new nodes will be assigned this attribute in proportion to the distribution of that attribute among nodes at time 1 (that is, the proportions set in the original network fornetest
). -
Value
: all new nodes will be assigned this specific value, with no variation. For example, the rules listattr.rules = list(race = "t1", sex = "current", status = "s")
specifies how the race, sex, and status attributes should be set for incoming nodes. By default, the rule is"current"
for all attributes except status, in which case it is"s"
(that is, all incoming nodes are susceptible).
Checkpointing Simulations
netsim
has a built-in checkpoint system to prevent losing computation work if the function is
interrupted (SIGINT, power loss, time limit exceeded on a computation cluster). When enabled,
each simulation will be saved every .checkpoint.steps
time steps. Then, if a checkpoint enabled
simulation is launched again with netsim
, it will restart at the last checkpoint available in
the saved data.
To enable the checkpoint capabilities of netsim
, two control arguments have to be set:
.checkpoint.steps
, which is a positive number of time steps to be run between each file save;
and .checkpoint.dir
, which is the path to a directory to save the checkpointed data. If
.checkpoint.dir
directory does not exist, netsim
will attempt to create it on the first
checkpoint save. With these two controls defined, one can simply re-run netsim
with the same
arguments to restart a set of simulations that were interrupted.
Simulations are checkpointed individually: for example, if 3 simulations are run on a single core,
the first 2 are finished, then the interruption occurs during the third, netsim
will only
restart the third one from the last checkpoint.
A .checkpoint.compress
argument can be set to overwrite the compress
argument in saveRDS
used to save the checkpointed data. The current default for saveRDS
is gunzip (gz)
, which
provides fast compression that usually works well on netsim
objects.
By default, if netsim
reaches the end of all simulations, the checkpoint data directory and its
content are removed before returning the netsim
object. The .checkpoint.keep
argument can be
set to TRUE
to prevent this removal to inspect the raw simulation objects.
New Modules
Base network models use a set of module functions that specify how the individual nodes in the
network are subjected to infection, recovery, demographics, and other processes. Core modules are
those listed in the .FUN
arguments. For each module, there is a default function used in
the simulation. The default infection module, for example, is contained in the infection.net
function.
For original models, one may substitute replacement module functions for any of the default
functions. New modules may be added to the workflow at each time step by passing a module function
via the ...
argument. Consult the New Network Models
tutorials. One may remove existing modules, such as arrivals.FUN
, from the workflow by setting
the parameter value for that argument to NULL
.
End Horizon
netsim
implements an "End Horizon" mechanism, where a set of modules are
removed from the simulation at a specific time step. This is enabled through
the end.horizon
parameter to control.net
.
This parameter must receive a list
with fields at
, the time step at which
the end horizon occurs, and modules
, a character vector with the names of
the modules to remove. (e.g 'list(at = 208, modules = c("arrivals.FUN",
"infections.FUN")))
See Also
Use param.net
to specify model parameters and init.net
to specify the initial conditions.
Run the parameterized model with netsim
.