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:
$$
w_{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
-
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.
-
Updated rdiffnet() in R/rdiffnet.r to accept exposure.mode.
- Added safety check to force
valued=TRUE when mode is stochastic.
Currently,$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.
rdiffnetand the underlyingexposurefunction calculate exposure deterministically (This implementation focuses on:
A: Stochastic Transmission (PR #68)
We added an
exposure.modeargument tordiffnet(and theexposurefunction) 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:
Mechanism: For each time step, transmission is determined by a Bernoulli trial. If successful, the link is treated as a full connection (weight = 1):
where:
Exposure Formula:$\tilde{E}_i$ is calculated as the ratio of realized transmission to potential contacts (Degree):
The exposure
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.modeargument tordiffnetto 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:
Completed Tasks
Updated
exposure()and its internal helpers inR/stats.Rto handleexposure.mode.cumadoptlists to arrays.Updated
rdiffnet()inR/rdiffnet.rto acceptexposure.mode.valued=TRUEwhen mode is stochastic.