Skip to contents

Core Simulation Functions

Primary functions for estimating network models, running epidemic simulations, and diagnosing model fit.

dcm()
Deterministic Compartmental Models
icm()
Stochastic Individual Contact Models
netsim()
Stochastic Network Models
netest()
Dynamic Network Model Estimation
netdx()
Dynamic Network Model Diagnostics
EpiModel-package EpiModel
Mathematical Modeling of Infectious Disease Dynamics

Model Inputs

Functions to specify parameters, initial conditions, and control settings for each model class, plus network setup utilities.

param.dcm()
Epidemic Parameters for Deterministic Compartmental Models
param.icm()
Epidemic Parameters for Stochastic Individual Contact Models
param.net()
Epidemic Parameters for Stochastic Network Models
init.dcm()
Initial Conditions for Deterministic Compartmental Models
init.icm()
Initial Conditions for Stochastic Individual Contact Models
init.net()
Initial Conditions for Stochastic Network Models
control.dcm()
Control Settings for Deterministic Compartmental Models
control.icm()
Control Settings for Stochastic Individual Contact Models
control.net()
Control Settings for Stochastic Network Models
dissolution_coefs()
Dissolution Coefficients for Stochastic Network Models
network_initialize()
Initialize Network Object
multilayer()
Specify Controls by Network

dat Object Accessors

Get and set node-level attributes, parameters, epidemic trackers, control settings, and initial conditions on the internal dat object used by network and ICM modules.

get_attr_list() get_attr() add_attr() set_attr() append_attr() remove_node_attr() get_epi_list() get_epi() add_epi() set_epi() get_param_list() get_param() add_param() set_param() get_control_list() get_control() get_network_control() add_control() set_control() get_init_list() get_init() add_init() set_init() get_core_attributes() append_core_attr()
Functions to Access and Edit the Main netsim_dat Object in Network Models
get_attr_history()
Extract the Attributes History from Network Simulations
get_attr_prop()
Proportional Table of Vertex Attributes
auto_update_attr()
Update Vertex Attributes for Incoming Vertices
overwrite_attrs()
Helper to use a data.frame to initialize some attributes
get_param_set()
Extract the Parameter Set from Network Simulations
epi_trackers()
Function to run the user-provided epi trackers
delete_attr()
Delete Elements from Attribute List

Network and Edgelist Functions

Tools for working with network edgelists, partnership queries, discordant pairs, cumulative edgelists, and network attributes.

discord_edgelist()
Discordant Edgelist
get_edgelist()
Get an Edgelist From the Specified Network
get_edgelists_df()
Get the Edgelist(s) from the Specified Network(s)
get_degree()
Get Individual Degree from Network or Edgelist
get_partners()
Return the Historical Contacts (Partners) of a Set of Index Nodes
get_discordant_edgelist()
Get Discordant Edgelist Based on Specified Status Variable
get_cumulative_edgelist()
Get a Cumulative Edgelist From a Specified Network
get_cumulative_edgelists_df()
Get the Cumulative Edgelists of a Model
get_cumulative_degree()
Return the Cumulative Degree of a Set of Index Nodes
as_cumulative_edgelist()
Convert an object to a cumulative_edgelist
update_cumulative_edgelist()
Update a Cumulative Edgelist of the Specified Network
dedup_cumulative_edgelist()
Deduplicate a cumulative edgelist by combining overlapping edges
as_tibble_edgelist()
Convert an Edgelist into a Tibble
edgelist_censor()
Table of Edge Censoring
get_network()
Extract Network Objects from Network Simulations
set_network()
Set Network State During netsim Simulation
get_nwparam()
Extract Network Model Parameters
get_network_attributes()
Get Network Attributes from a Network Object
get_attr_list() get_attr() add_attr() set_attr() append_attr() remove_node_attr() get_epi_list() get_epi() add_epi() set_epi() get_param_list() get_param() add_param() set_param() get_control_list() get_control() get_network_control() add_control() set_control() get_init_list() get_init() add_init() set_init() get_core_attributes() append_core_attr()
Functions to Access and Edit the Main netsim_dat Object in Network Models
get_vertex_attribute()
Get Vertex Attribute on Network Object
set_vertex_attribute()
Set Vertex Attribute on Network Object
add_vertices()
Fast Version of network::add.vertices for Edgelist-formatted Network
delete_vertices()
Fast Version of network::delete.vertices for Edgelist-formatted Network
delete_edges()
Remove Edges That Include Specified Vertices
copy_datattr_to_nwattr()
Copy Vertex Attributes from the netsim_dat List to the Network Objects
copy_nwattr_to_datattr()
Copy Vertex Attributes From Network to netsim_dat List

Output Extraction and Analysis

Convert simulation output to data frames, extract networks and transmission matrices, derive new statistics, and merge or truncate results.

as.data.frame(<dcm>)
Extract Model Data for Deterministic Compartmental Models
as.data.frame(<icm>) as.data.frame(<netsim>)
Extract Model Data for Stochastic Models
as.data.frame(<netdx>)
Extract Timed Edgelists for netdx Objects
as.epi.data.frame()
Validate and Convert to epi.data.frame
get_sims()
Extract Network Simulations
is.transmat() get_transmat()
Extract Transmissions Matrix from Network Epidemic Model
set_transmat()
Save Transmission Matrix
as.network(<transmat>)
Convert transmat Infection Tree into a network Object
as.phylo(<transmat>)
Convert transmat Infection Tree into a phylo Object
get_nwstats()
Extract Network Statistics from netsim or netdx Object
mutate_epi()
Add New Epidemiology Variables
truncate_sim()
Truncate Simulation Time Series
merge(<icm>)
Merge Data across Stochastic Individual Contact Model Simulations
merge(<netsim>)
Merge Model Simulations across netsim Objects

Visualization

Plot methods for epidemic trajectories, network diagnostics, transmission trees, and interactive exploration.

plot(<dcm>)
Plot Data from a Deterministic Compartmental Epidemic Model
plot(<icm>)
Plot Data from a Stochastic Individual Contact Epidemic Model
plot(<netsim>)
Plot Data from a Stochastic Network Epidemic Model
plot(<netdx>)
Plot Dynamic Network Model Diagnostics
plot(<transmat>)
Plot transmat Infection Tree in Three Styles
plot(<epi.data.frame>)
Plot Epidemic Model Results From a Netsim Data.Frame
comp_plot()
Plot Compartment Diagram for Epidemic Models
geom_bands()
ggplot2 Geom for Quantile Bands
epiweb()
EpiModel Web
brewer_ramp()
RColorBrewer Color Ramp for EpiModel Plots
color_tea()
Create a TEA Variable for Infection Status for ndtv Animations
print(<dcm>)
Print Method for DCM Objects
print(<icm>)
Print Method for ICM Objects
print(<netsim>)
Print Method for Network Model Simulations
print(<netdx>)
Utility Function for Printing netdx Object
summary(<dcm>)
Summary Model Statistics
summary(<icm>)
Summary Model Statistics
summary(<netsim>)
Summary Model Statistics
summary(<netest>)
Summary for Network Model Fit
print_nwstats_table()
Print Helper For Network Stats Tables
make_stats_table()
Create a Summary Table of Simulation Statistics

Built-in ICM Modules

Default module functions for stochastic individual contact models.

initialize.icm()
Initialization: icm Module
infection.icm()
Primary Infection Module for icm
infection.icm.bip()
Primary Infection Module for icm
recovery.icm()
Recovery: icm Module
recovery.icm.bip()
Recovery: icm Module
arrivals.icm()
Arrivals: icm Module
arrivals.icm.bip()
Arrivals: Bipartite icm Module
departures.icm()
Departure: icm Module
departures.icm.bip()
Departure: Bipartite icm Module
prevalence.icm()
Get Epidemic Output from icm Model
prevalence.icm.bip()
Get Epidemic Output from icm Model
init_status.icm()
Disease Status Initialization Module for icm
saveout.icm()
Save icm Data to Output List Format
verbose.icm()
Progress Print Module for Stochastic Individual Contact Models
modules.icm
Modules for Stochastic Individual Contact Models
test_icm()
Test the Model Output from a Stochastic Individual Contact Model

Built-in Network Modules

Default module functions for stochastic network models.

initialize.net()
Initialization: netsim Module
infection.net()
Primary Infection Module for netsim
infection.2g.net()
Primary Infection Module for netsim
recovery.net()
Recovery: netsim Module
recovery.2g.net()
Recovery: netsim Module
arrivals.net()
Arrivals: netsim Module
arrivals.2g.net()
Arrivals: netsim Module
departures.net()
Departures: netsim Module
departures.2g.net()
Departures: netsim Module
nwupdate.net()
Dynamic Network Updates
edges_correct()
Adjustment for the Edges Coefficient with Changing Network Size
prevalence.net()
Get Epidemic Output from netsim Model
init_status.net()
Disease Status Initialization Module for netsim
saveout.net()
Save netsim Data to Output List Format
verbose.net()
Progress Print Module for Stochastic Network Models
process_out.net()
Save a List of netsim Data to Output List Format
modules.net
Modules for Stochastic Network Models
test_net()
Test the Model Output from a Network Model

DCM ODE Systems

Built-in ODE model functions for deterministic compartmental models (SI, SIR, SIS; one-group and two-group; open and closed populations).

mod_SI_1g_cl() mod_SI_1g_op() mod_SI_2g_cl() mod_SI_2g_op() mod_SIR_1g_cl() mod_SIR_1g_op() mod_SIR_2g_cl() mod_SIR_2g_op() mod_SIS_1g_cl() mod_SIS_1g_op() mod_SIS_2g_cl() mod_SIS_2g_op()
Deterministic Compartmental Model Functions
saveout.dcm()
Save dcm Data to Output List Format
verbose.dcm()
Progress Print Module for Deterministic Compartmental Models
crosscheck.dcm()
Cross Checking of Inputs for Deterministic Compartmental Models
crosscheck.icm()
Cross Checking of Inputs for Stochastic Individual Contact Models
crosscheck.net()
Cross Checking of Inputs for Stochastic Network Models

Extension API

Functions for building custom modules with arbitrary disease states, demographics, and interventions. These are the building blocks for the EpiModel extension framework.

create_dat_object()
Create a Minimal netsim_dat Main List Object for a Network Model
arrive_nodes()
Arrive New Nodes to the netsim_dat Object
depart_nodes()
Depart Nodes from the netsim_dat Object
get_current_timestep()
Return the Current Timestep
set_current_timestep()
Set the Current Timestep
increment_timestep()
Increment the Current Timestep
record_attr_history()
Record Attribute History
record_raw_object()
Record an Arbitrary Object During a Simulation
simulate_dat()
Simulate a Network for a Specified Number of Time Steps
make_restart_point()
Make a Lightweight Restart Point From a netsim Object with tergmLite
get_args()
Get Arguments from EpiModel Parameterization Functions
get_modules()
Get the List of Modules
set_modules()
Set the List of Modules
remove_modules()
Remove a Set of Modules From the Module List
make_module_list()
Populate the Module List After the Initialization Module is run
get_unique_ids() get_posit_ids()
Convert Unique Identifiers to/from Positional Identifiers
is_active_posit_ids()
Are These Nodes Active (Positional IDs)
is_active_unique_ids()
Are These Nodes Active (Unique IDs)
init_nets()
Network Data and Stats Initialization
resim_nets()
Resimulate Dynamic Network at Time 2+
sim_nets_t1()
Initialize Networks Used in netsim
summary_nets()
Extract Summary Statistics of Networks Used in netsim
trim_netest()
Function to Reduce the Size of a netest Object
check_degdist_bal()
Check Degree Distribution for Balance in Target Statistics

Reachability Analysis

Identify transmission chains and reachable nodes in a network.

get_forward_reachable() get_backward_reachable()
Get the Forward or Backward Reachable Nodes for a Set of Nodes
get_adj_list()
Returns an adjacency list from an edge list
get_subnet_adj_list()
Return an adjacency list of subnets
get_connected_nodes()
Returns all the node connected directly or indirectly to a set of nodes

Scenarios and Parameter Tools

Create and apply parameter scenarios for sensitivity analyses, including table-based parameter input and random parameter generation.

create_scenario_list()
Make a list of EpiModel scenarios from a data.frame of scenarios
use_scenario()
Apply a scenario object to a param.net object
update_params()
Update Model Parameters for Stochastic Network Models
param.net_from_table()
Parameters List for Stochastic Network Models from a Formatted Data Frame
param.net_to_table()
Coerce a list of parameters to a long.param.df
param_random()
Create a Value Sampler for Random Parameters
generate_random_params()
Generate Values for Random Parameters
format_param()
Format One Parameter for Printing with the print.param.xxx Functions

Custom ERGM Terms

Custom exponential-family random graph model terms provided by EpiModel for use in network model formulas.

InitErgmTerm.fuzzynodematch()
Definition for fuzzynodematch ERGM Term
InitErgmTerm.absdiffby()
Definition for absdiffby ERGM Term
InitErgmTerm.absdiffnodemix()
Definition for absdiffnodemix ERGM Term
get_formula_term_attr()
Output ERGM Formula Attributes into a Character Vector
get_network_term_attr()
Output Network Attributes into a Character Vector

Utilities

ssample()
Stable Sampling Function
padded_vector()
Grow a Vector to a Given Size, Padding it With Empty Elements
apportion_lr()
Apportion Using the Largest Remainder Method
mcat()
Write Out Test Progress to Console
idgroup()
Group Numbers for Two-Group Network
update_dissolution()
Adjust Dissolution Component of Network Model Fit
update_list()
Update List x Using the Elements of List new.x.
common_updater()
Update Either the "param" or "control" List
check_attr_lengths()
Check that All Attributes in the Main netsim_dat Object are of Equal Length
check_end_horizon_control()
Check the format of the end.horizon control
trigger_end_horizon()
Function to Trigger the End Horizon
netsim_cond_msg()
Message to Find in Which Module a condition Occurred
netsim_error_logger()
Handle the Logging of Traceback and Dumping of Frames on Error
tedgelist_to_toggles()
Convert Timed Edgelist to Matrix of Toggles
toggles_to_diss_stats()
Convert Matrix of Toggles to Dissolution and Duration Statistics