epiworldR Sunbelt 2023 Workshop


# Creating a model
mymodel <- ModelSEIRCONN(
  name = "Nasty virus", n = 10000, prevalence = .001, contact_rate = 4,
  transmission_rate = .4, incubation_days = 7, recovery_rate = 1/7
) |> verbose_off() 

# Adding a virus
add_virus(mymodel, virus("Nasty virus 2", .5, .3), proportion = .001)

# Renaming the model
set_name(mymodel, mname = "SEIR COVID-19 model")

# Running the model
run(mymodel, ndays = 100)

op <- par(mfrow = c(2, 2), mar = par()$mar * c(1, 1, 1/2, 0))

Figure 1: ?(caption)

The epiworldR R package is a wrapper of the C++ library epiworld. It provides a general framework for modeling disease transmission using agent-based models wiki. Some main features include:

sir <- ModelSIR(
  name           = "COVID-19",
  prevalence     = .01,
  transmission_rate = .5,
  recovery_rate       = .5
  ) |>
    # Adding a Small world population 
    agents_smallworld(n = 500, k = 10, d = FALSE, p = .01) |>
    # Running the model for 50 days
    verbose_off() |>
    run(ndays = 50, seed = 1912)

## Transmission network
net <- get_transmissions(sir)

## Plotting
x <- graph_from_edgelist(as.matrix(net[,2:3]) + 1)

nplot(x, edge.curvature = 0, edge.color = "gray", skip.vertex=TRUE)

Figure 2: Transmission network built using the netplot R package


Thank you for joining the epiworldR workshop at the Sunbelt 2023 conference. Our schedule for today is as follows:

  • Setup (10 min)
  • Part 1: Basic modeling (50 min)
  • Break (10 min)
  • Part 2a: Social Network Analysis (30 min)
  • Part 2b: Adding multiple diseases & tools (30 min)
  • Break (10 min)
  • Part 3: Multiple runs (40 min)

You are welcome to use your personal computer, but we also have an online RStudio server available for you to use.1


You can install the development version of epiworldR from GitHub with:

# install.packages("devtools")

Agent-Based Modeling

Agent-based modeling (ABM) is a powerful computational approach that enables the simulation and analysis of complex systems by representing individual agents and their interactions within an environment. ABM provides a bottom-up perspective, allowing for the examination of emergent phenomena arising from the collective behavior of autonomous agents. By capturing the heterogeneity, autonomy, and adaptive nature of agents, ABM offers a versatile tool for investigating various domains, including social sciences, economics, biology, and epidemiology, offering valuable insights into the dynamics and patterns that emerge from the interactions of individual entities within a larger system.


epiworldR focuses heavily on epidemiological applications to social networking. Below are some common terms that will be used throughout.

SEIR, SIR, SIS, etc.:
These are epidemiological models that are used to analyze the spread and dynamics of diseases in a population. These models are a combination or selection of the states susceptible, exposed, infected, and/or recovered, in which all individuals in a population can be categorized in.

SEIR connected (SEIRCONN), SIR connected (SIRCONN), etc.:
These are epidemiological models that are similar to their above counterparts (SEIR, SIR, etc.), but with the assumption that each individual agent is connected to all other agents.

Reproductive number:
The average number of secondary transmissions from one infected person. For example, a reproductive number of 2.0 indicates that one infected person transmits the disease to two other people in the population on average.

The the occurrence of new cases of disease or injury in a population over a specified period of time. Specifically, daily incidence is computed in epiworldR.

About the instructors

Dr. George G. Vega Yon is a Research Assistant Professor of Epidemiology at the Department of Internal Medicine at the University of Utah.

Derek S. Meyer is a Research Assistant and M.Stat. student in Biostatistics at the Department of Internal Medicine at the University of Utah.


  1. Please note that the online RStudio server and your data stored in it will be available for two weeks after the workshop. After that, the server will be shut down and all data will be deleted. If you would like to keep your data, please download it before the server is shut down.↩︎