play {manynet} | R Documentation |
Making diffusion models on networks
Description
These functions simulate diffusion or compartment models upon a network.
-
play_diffusion()
runs a single simulation of a compartment model, allowing the results to be visualised and examined. -
play_diffusions()
runs multiple simulations of a compartment model for more robust inference.
These functions allow both a full range of compartment models, as well as simplex and complex diffusion to be simulated upon a network.
Usage
play_diffusion(
.data,
seeds = 1,
contact = NULL,
prevalence = 0,
thresholds = 1,
transmissibility = 1,
latency = 0,
recovery = 0,
waning = 0,
immune = NULL,
steps
)
play_diffusions(
.data,
seeds = 1,
contact = NULL,
prevalence = 0,
thresholds = 1,
transmissibility = 1,
latency = 0,
recovery = 0,
waning = 0,
immune = NULL,
steps,
times = 5,
strategy = "sequential",
verbose = FALSE
)
Arguments
.data |
An object of a manynet-consistent class:
|
seeds |
A valid mark vector the length of the number of nodes in the network. |
contact |
A matrix or network that replaces ".data" with some
other explicit contact network, e.g.
|
prevalence |
The proportion that global prevalence contributes to diffusion. That is, if prevalence is 0.5, then the current number of infections is multiplied by 0.5 and added "prevalence" is 0 by default, i.e. there is no global mechanism. Note that this is endogenously defined and is updated at the outset of each step. |
thresholds |
A numeric vector indicating the thresholds each node has. By default 1. A single number means a generic threshold; for thresholds that vary among the population please use a vector the length of the number of nodes in the network. If 1 or larger, the threshold is interpreted as a simple count of the number of contacts/exposures sufficient for infection. If less than 1, the threshold is interpreted as complex, where the threshold concerns the proportion of contacts. |
transmissibility |
The transmission rate probability,
|
latency |
The inverse probability those who have been exposed
become infectious (infected), |
recovery |
The probability those who are infected
recover, |
waning |
The probability those who are recovered
become susceptible again, |
immune |
A logical or numeric vector identifying nodes that begin the diffusion process as already recovered. This could be interpreted as those who are vaccinated or equivalent. Note however that a waning parameter will affect these nodes too. By default NULL, indicating that no nodes begin immune. |
steps |
The number of steps forward in the diffusion to play.
By default the number of nodes in the network.
If |
times |
Integer indicating number of simulations.
By default |
strategy |
If |
verbose |
Whether the function should report on its progress.
By default FALSE. See |
Simple and complex diffusion
By default, the function will simulate a simple diffusion process in
which some infectious disease or idea diffuses from seeds through
contacts at some constant rate (transmissibility
).
These seeds
can be specified by a vector index
(the number of the position of each node in the network that should serve as a seed)
or as a logical vector where TRUE is interpreted as already infected.
thresholds
can be set such that adoption/infection requires more than one
(the default) contact already being infected.
This parameter also accepts a vector so that thresholds can vary.
Complex diffusion is where the thresholds
are defined less than one.
In this case, the thresholds are interpreted as proportional.
That is, the threshold to adoption/infection is defined by the
proportion of the node's contacts infected.
Nodes that cannot be infected can be indicated as immune
with a logical vector or index, similar to how seeds
are identified.
Note that immune
nodes are interpreted internally as Recovered (R)
and are thus subject to waning
(see below).
Compartment models
Compartment models are flexible models of diffusion or contagion, where nodes are compartmentalised into one of two or more categories.
The most basic model is the SI model.
The SI model is the default in play_diffusion()
/play_diffusions()
,
where nodes can only move from the Susceptible (S) category to the
Infected (I) category.
Whether nodes move from S to I depends on whether they are exposed
to the infection, for instance through a contact,
the transmissibility
of the disease,
and their thresholds
to the disease.
Another common model is the SIR model.
Here nodes move from S to I, as above, but additionally they can
move from I to a Recovered (R) status.
The probability that an infected node recovers at a timepoint
is controlled by the recovery
parameter.
The next most common models are the SIS and SIRS models.
Here nodes move from S to I or additionally to R, as above,
but additionally they can move from I or R back to a Susceptible (S) state.
This probability is governed by the waning
parameter.
Where recover > 0
and waning = 1
, the Recovery (R) state will be skipped
and the node will return immediately to the Susceptible (S) compartment.
Lastly, these functions also offer the possibility of specifying
a latency period in which nodes have been infected but are not yet infectious.
Where latency > 0
, an additional Exposed (E) compartment is introduced
that governs the probability that a node moves from this E compartment
to infectiousness (I).
This can be used in in SEI, SEIS, SEIR, and SEIRS models.
See Also
Other makes:
create
,
generate
,
learning
,
read
,
write()
Other models:
learning
Other diffusion:
measure_infection
,
measure_net_diffusion
,
measure_node_diffusion
,
member_diffusion
Examples
smeg <- generate_smallworld(15, 0.025)
plot(play_diffusion(smeg, recovery = 0.4))
#graphr(play_diffusion(ison_karateka))
plot(play_diffusions(smeg, times = 10))