Skip to content

Add stochastic transmission and probabilistic adoption modes #67

@aoliveram

Description

@aoliveram

Currently, rdiffnet and the underlying exposure function calculate exposure deterministically ($E = W \times A$). To support more general diffusion processes, specifically Agent-Based Models (ABM) that require stochastic mechanics, we have introduced stochasticity into the transmission process.

This implementation focuses on:

A: Stochastic Transmission (PR #68)

We added an exposure.mode argument to rdiffnet (and the exposure function) to account for "Noisy Links".

Options: "deterministic" (default) vs "stochastic".

Logic: In stochastic mode, the input adjacency matrix $\mathbf{X}$ is treated as a matrix of transmission probabilities.
For example, derived from social distance:

$$ \mathbf{X}_{ij} = \sigma(h - d_{ij}) $$

Mechanism: For each time step, transmission is determined by a Bernoulli trial. If successful, the link is treated as a full connection (weight = 1):

$$ \text{Transmitted}_{ij} = \begin{cases} 1 & \text{if } U_{ij} < \mathbf{X}_{ij} \\ 0 & \text{otherwise} \end{cases} $$

where:

$$ U_{ij} \sim \text{Unif}(0, 1) $$

Exposure Formula:
The exposure $\tilde{E}_i$ is calculated as the ratio of realized transmission to potential contacts (Degree):

$$ \tilde{E}_i = \frac{ \sum_{j \neq i} \mathbb{I}(U_{ij} < \mathbf{X}_{ij}) , a_j }{ \sum_{j \neq i} 1 } $$

The denominator is the Degree of the node (count of neighbors), representing the total number of potential contacts, while the numerator sums only the successful transmissions.

B: Probabilistic Adoption

We can add an adopt.mode argument to rdiffnet to account for "Noisy Nodes".

Options: "deterministic" (default, threshold comparison) vs "probabilistic" (logit / probability function).

Logic: In probabilistic mode, adoption is not guaranteed when exposure exceeds a threshold. Instead, adoption is a stochastic event based on a probability function.

Formula:

$$ P(\text{adopt}_i) = \text{logit}^{-1} \left( \beta \cdot \text{exposure}_i + \dots \right) $$

Completed Tasks

  1. Updated exposure() and its internal helpers in R/stats.R to handle exposure.mode.

    • Implemented "Bernoulli-to-Binary" logic: Success = 1, Failure = 0.
    • Changed normalization for stochastic mode to use Degree (sum of 1s) instead of sum of weights.
    • Fixed multi-behavior support by converting cumadopt lists to arrays.
  2. Updated rdiffnet() in R/rdiffnet.r to accept exposure.mode.

    • Added safety check to force valued=TRUE when mode is stochastic.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions