Skip to content

Sampling Contacts

Overview

Agents' interactions in epiworld are implemented in various ways. Depending on the model, contacts will be drawn either directly from agents' connections (network models) or via sampling using a binomial distribution (mixing models). This section explains some of the optimizations implemented in the software to reduce computation time when modeling contacts between agents.

Drawing contacts

In networked models, we assume that all contacts are drawn at each step of the simulation (a deterministic process). The randomness comes from the probability of transmission, which is given by the virus, the infectious agent, and susceptible agent. In the case of the mixing models (connected models where interaction happens as a function of a contact rate), we sample directly from the number of infected individuals. Mathematically, the convolution of infected and not-infected contacts distributes Binomial with parameters:

\[ X_\text{infected} + X_{\text{not infected}} \sim \text{Binomial}\left(n, \frac{c}{n}\right) \]

Where \(X_\text{infected}\sim \text{Binomial}\left(n_\text{infected}, \frac{c}{n}\right)\). Since only infectious individuals (which we are referring to as infected) can change the status of susceptible individuals, the drawing process only draws individuals from the group of infectious individuals.

It is important to note that, in the case of models that remove agents through quarantine processes or similar, the number of available individuals for contact changes, which in turn changes the probability of contacting infected individuals. We describe this in more detail down below.

Mixing Matrix Models

In models featuring mixing matrices, the process unfolds similarly, with the main difference being that the overall number of contacts does not follow a Binomial distribution. Specifically, given individual \(i\) in group \(g\), the number of contacts from group \(j\) is:

\[ X(g,j) = X(g,j)_\text{infected} + X(g,j)_\text{not infected} \sim \text{Binomial}\left(n(j), \frac{c}{n(j)}\times A(g, j)\right) \]

Where \(n(j)\) is the number of individuals in group \(j\) and \(A(g, j)\) is the \(gj\)-th entry in the mixing matrix indicating the proportion of contacts individuals from group \(g\) will have with \(j\). The matrix \(A\) is row-stochastic, meaning that its rows add up to one. This way, we have that the expected number of contacts individual \(i\) will make is

\[ \mathbb{E}\left[\sum_j X(g,j) \right] = \sum_j \mathbb{E}\left[X(g,j) \right] = \sum_j n(j) \times \frac{c}{n(j)}\times A(g, j) = c \sum_j A(g, j) = c \]

Where the last equality follows from \(A\) being row-stochastic. As in the more general mixing models, the number of infected individuals to be drawn is \(X(g,j)\sim\text{Binomial}\left(n(j)_\text{infected}, \frac{c}{n(j)}\times A(g, j)\right)\).

Mixing models with quarantine

When the model features a quarantine process, or any other process that may affect the number of agents present in the model, the parameters of the Binomial distribution may change. In the Measles models (ModelMeaslesSchool, MeaslesMixing, and ModelMeaslesRiskQuarantine), quarantined agents are removed from the contact pool, which changes the contact probability and increases the chances of contacting an infected individual. Looking again at the probability of contacting infected individuals:

\[ X(g,j)\sim\text{Binomial}\left(n(j)_\text{infected}, \frac{c}{n(j)}\times A(g, j)\right) \]

As \(n(j)\)—the total number of available agents in group \(j\)—decreases, the expected value of \(X(g, j)\) increases. This is especially true in those cases where the number of quarantined agents is large.

Probability of Infection

Generally, epiworld assumes that at each step of the simulation, susceptible agents can acquire the disease from at most one infected agent. The probability of transmission from \(i\) to \(j\) is given by the following formula:

\[ P(i\to j| \text{at most one}) = \frac{p_{ij} \times \prod_{k\neq i}\left(1 - p_{kj}\right)}{\prod_k\left(1 - p_{kj}\right) + \sum_k p_{kj} \times \prod_{l\neq k}\left(1 - p_{lj}\right)} \]

The adjusted probabilities \(p_{ij}\) are computed as a function of \(i\), \(j\), and the virus. The following section describes how these probabilities are computed.

Adjusted probabilities

Viruses and tools provide a way to adjust how agents move between states. Viruses in epiworld contain various baseline probabilities used across models, including transmission, recovery, and death. Tools, on the other hand, alter these probabilities by reducing or increasing them, affecting agents' susceptibility, infectiousness, recovery, and death probabilities. Currently, tools alter these probabilities by a constant factor,

\[ p_{ij} = p_{v} \times \left(1 - factor_{host}\right) \times \left(1 - factor_{target}\right) \]

Where \(p_{v}\) is the raw transmission probability of the virus \(v\), and \(factor_{t}\) are the increasing/reducing factors tools have over the process. For example, if p_v was 0.9, the host was wearing a mask, so \(factor_{\text{mask host}} = 0.3\) and the target was vaccinated, so \(factor_{\text{vaccinated target}} = 0.5\), then the adjusted probability \(p_{ij}\) would be \(0.9 \times (1 - 0.3) \times (1 - 0.5) = 0.27\).

When agents have more than one tool, factors are combined as follows:

\[ factor_{agent} = 1 - \prod_{t\in tools_{agent}}\left(1 - factor_{t}\right) \]

Therefore, for example, a vaccinated agent wearing a mask would have a factor of \(1 - (1 - 0.30) \times (1 - 0.5) = 0.65\). The adjusted probabilities principle also applies to recovery rates in the SIR and SEIR models.