netdiffuseR currently lacks metrics for epidemiological analysis of contact networks. The diffnet class treats adoption as permanent (like a SI model), hazard_rate() is network-blind, there is no way to store a transmission tree, and stochastic transmission (already in progress on the stochastic-transmission branch) supports only a sigmoid kernel (not well-suited for epidemiological simulations).
What we should do
-
Time of Disadoption. Add an optional $tod slot to diffnet parallel in shape to $toa. Both should be matrices N × K to handle k reinfection cycles, and be a vector when one episode per node.
-
Reproductive number. We can construct a native function repr_number() that mirrors epiworldR::get_reproductive_number() exactly: offspring count aggregated by (source, source_exposure_date) from the transmission tree. No other R_0 flavour in this PR.
-
Supporting epi metrics. secondary_attack_rate(), generation_time(), survival_curve(), peak_prevalence(), peak_time(). All native, and relatively simple once with the adoption tree.
-
Transmission tree. We should add an optional $transmission slot on diffnet (schema identical to epiworldR::get_transmissions()). Tested first with the Epigames histories.csv and checked if it fits well with the one provided by Andres's scripts.
-
Stochastic transmission. 1) Generalise the existing stochastic-transmission work: add a pluggable link_fun parameter to allocate a preferred function (linear, sigmoid, Wells-Riley, or a function given by the user); and 2) add a adoption_model = "logit" path in rdiffnet() with beta0 + beta_expo parameters.
Key aspects
- Zero new dependencies.
- Backward compatible: When
$tod and $transmission are NULL, every existing function returns identical results.
Origin of prior work
This PR integrates two existing branches:
stochastic-transmission (link-level Bernoulli, sigmoid kernel).
issue-75-epigames-dynamic-attrs (Epigames dataset, dynamic attrs, collapse_timeframes).
Both will be merged into a new issue-XX-epidemiological-metrics branch.
netdiffuseRcurrently lacks metrics for epidemiological analysis of contact networks. Thediffnetclass treats adoption as permanent (like a SI model),hazard_rate()is network-blind, there is no way to store a transmission tree, and stochastic transmission (already in progress on thestochastic-transmissionbranch) supports only a sigmoid kernel (not well-suited for epidemiological simulations).What we should do
Time of Disadoption. Add an optional
$todslot todiffnetparallel in shape to$toa. Both should be matrices N × K to handle k reinfection cycles, and be a vector when one episode per node.Reproductive number. We can construct a native function
repr_number()that mirrorsepiworldR::get_reproductive_number()exactly: offspring count aggregated by(source, source_exposure_date)from the transmission tree. No other R_0 flavour in this PR.Supporting epi metrics.
secondary_attack_rate(),generation_time(),survival_curve(),peak_prevalence(),peak_time(). All native, and relatively simple once with the adoption tree.Transmission tree. We should add an optional
$transmissionslot ondiffnet(schema identical toepiworldR::get_transmissions()). Tested first with the Epigameshistories.csvand checked if it fits well with the one provided by Andres's scripts.Stochastic transmission. 1) Generalise the existing
stochastic-transmissionwork: add a pluggablelink_funparameter to allocate a preferred function (linear, sigmoid, Wells-Riley, or a function given by the user); and 2) add aadoption_model = "logit"path inrdiffnet()withbeta0+beta_expoparameters.Key aspects
$todand$transmissionareNULL, every existing function returns identical results.Origin of prior work
This PR integrates two existing branches:
stochastic-transmission(link-level Bernoulli, sigmoid kernel).issue-75-epigames-dynamic-attrs(Epigames dataset, dynamic attrs,collapse_timeframes).Both will be merged into a new
issue-XX-epidemiological-metricsbranch.