Skip to contents

Package Overview

EpiModel-package EpiModel
Mathematical Modeling of Infectious Disease Dynamics

Model Inputs

Specify epidemic parameters, initial conditions, and control settings for each model class.

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

Epidemic Simulation

Run deterministic compartmental models, stochastic individual contact models, or stochastic network models.

dcm()
Deterministic Compartmental Models
icm()
Stochastic Individual Contact Models
netsim()
Stochastic Network Models

Network Model Setup & Estimation

Create and configure network objects, estimate ERGM/TERGM-based network models from target statistics, diagnose model fit, and compute dissolution coefficients. These functions support the additional estimation step required by network models before simulation with netsim().

network_initialize()
Initialize Network Object
multilayer()
Specify Controls by Network
get_vertex_attribute()
Get Vertex Attribute on Network Object
set_vertex_attribute()
Set Vertex Attribute on Network Object
netest()
Dynamic Network Model Estimation
netdx()
Dynamic Network Model Diagnostics
dissolution_coefs()
Dissolution Coefficients for Stochastic Network Models
update_dissolution()
Adjust Dissolution Component of Network Model Fit
trim_netest()
Function to Reduce the Size of a netest Object
check_degdist_bal()
Check Degree Distribution for Balance in Target Statistics

Simulation Output

Extract, transform, merge, and truncate simulation results. Convert to data frames, derive new epi statistics, subset simulations, and create restart checkpoints.

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
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
get_network()
Extract Network Objects from Network Simulations
get_nwstats()
Extract Network Statistics from netsim or netdx Object
get_nwparam()
Extract Network Model Parameters
get_param_set()
Extract the Parameter Set from Network Simulations
get_attr_history()
Extract the Attributes History from Network Simulations
make_restart_point()
Make a Lightweight Restart Point From a netsim Object with tergmLite

Transmission & Reachability Analysis

Extract transmission matrices, construct phylogenies from transmission trees, and trace forward and backward reachable nodes through cumulative contact histories.

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_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

Visualization

Plot epidemic trajectories, network diagnostics, transmission trees, and epi data frames. Includes ggplot2 extensions and an interactive Shiny-based explorer.

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

Scenarios & Sensitivity Analysis

Build parameter scenarios for batch sensitivity analyses, convert between list and tabular parameter formats, and generate random parameter draws.

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

Extension API: Module Framework

Core framework for building custom network model modules with arbitrary disease states, demographics, and interventions. Manage module registration, timestep control, demographic flows, and simulation execution.

create_dat_object()
Create a Minimal netsim_dat Main List Object for a Network Model
simulate_dat()
Simulate a Network for a Specified Number of Time Steps
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_current_timestep()
Return the Current Timestep
set_current_timestep()
Set the Current Timestep
increment_timestep()
Increment the Current Timestep
get_args()
Get Arguments from EpiModel Parameterization Functions
arrive_nodes()
Arrive New Nodes to the netsim_dat Object
depart_nodes()
Depart Nodes from the netsim_dat Object
record_raw_object()
Record an Arbitrary Object During a Simulation

Extension API: State Accessors

Get, set, and manage node-level attributes, epidemic trackers, parameters, control settings, and initial conditions on the internal dat simulation state 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_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
delete_attr()
Delete Elements from Attribute List
epi_trackers()
Function to run the user-provided epi trackers
record_attr_history()
Record Attribute History
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)

Extension API: Edgelist & Partnership Queries

Query the current network state within modules: extract edgelists, look up partnerships and degree, identify discordant pairs, and manage cumulative edgelist tracking.

get_edgelist()
Get an Edgelist From the Specified Network
get_edgelists_df()
Get the Edgelist(s) from the Specified Network(s)
discord_edgelist()
Discordant Edgelist
get_discordant_edgelist()
Get Discordant Edgelist Based on Specified Status Variable
get_degree()
Get Individual Degree from Network or Edgelist
get_partners()
Return the Historical Contacts (Partners) of a Set of Index Nodes
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

Extension API: Network Operations

Initialize, resimulate, and summarize networks within modules. Manage network objects, vertices, edges, and attribute synchronization between dat and network representations.

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
set_network()
Set Network State During netsim Simulation
get_network_attributes()
Get Network Attributes from a 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

Built-in 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

Built-in ICM Modules

Default module functions for stochastic individual contact models (one-group and two-group/bipartite).

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 (one-group and two-group).

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

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

Internal helpers, input validation, and low-level support functions.

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
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_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