These functions allow measurement of various features of a diffusion process:
node_by_adopt_time(): Measures the number of time steps until
nodes adopt/become infected
node_by_adopt_threshold(): Measures nodes' thresholds from the amount
of exposure they had when they became infected
node_by_adopt_recovery(): Measures the average length nodes that become
infected remain infected in a compartmental model with recovery
node_by_adopt_exposure(): Measures how many exposures nodes have to
a given mark
node_by_adopt_time(.data, attribute = "diffusion")
node_by_adopt_threshold(
.data,
normalized = TRUE,
lag = 1,
direction = c("in", "out", "all"),
attribute = "diffusion"
)
node_by_adopt_recovery(.data, attribute = "diffusion")
node_by_adopt_exposure(
.data,
mark,
time = 0,
direction = c("in", "out", "all"),
attribute = "diffusion"
)A network object of class stocnet, igraph, tbl_graph, network, or similar.
Internally any of these will be coerced to an efficient implementation.
For more information on possible coercions, see e.g. manynet::as_stocnet().
Name of the nodal attribute that holds the diffusion,
as its start state on the nodes and as its changes.
By default "diffusion", as in play_diffusion().
Logical scalar, whether scores are normalized. Different denominators may be used depending on the measure, whether the object is one-mode or two-mode, and other arguments. By default TRUE.
The number of time steps back upon which the thresholds are
inferred.
By default lag = 1, which counts only the alters that adopted
before the node did.
lag = 0 also counts the alters that adopted at the same time step.
Character string, "in" counts the exposure that arrives along ties from adopters to the node, "out" along ties from the node to adopters, and "all" along both. By default "in", so contagion travels in the direction of the arcs. Undirected networks give the same result for every direction.
A valid 'node_mark' object or logical vector (TRUE/FALSE) of length equal to the number of nodes in the network.
A time point until which infections/adoptions should be
identified. By default time = 0.
A node_measure numeric vector the length of the nodes in the network,
providing the scores for each node.
If the network is labelled,
then the scores will be labelled with the nodes' names.
The object also carries the measure it computed, the range its values
can fall within, and whether and how those values were normalized.
These are shown as a one-line header when the object is printed.
Where a measure offers a choice between several ways of counting the
same thing, it also carries the variant it used.
All can be retrieved with attr().
node_by_adopt_time() measures the time units it took
until each node became infected.
Note that an adoption time of 0 indicates that this was a seed node.
node_by_adopt_threshold() infers nodes' thresholds based on how much
exposure they had when they were infected.
This inference is of course imperfect,
especially where there is a sudden increase in exposure,
but it can be used heuristically.
In a threshold model,
nodes activate when \(\sum_{j:\text{active}} w_{ji} \geq \theta_i\),
where \(w\) is some (potentially weighted) matrix,
\(j\) are some already activated nodes,
and \(theta\) is some pre-defined threshold value.
Where a fractional threshold is used, the equation is
\(\frac{\sum_{j:\text{active}} w_{ji}}{\sum_{j} w_{ji}} \geq \theta_i\).
That is, \(theta\) is now a proportion,
and works regardless of whether \(w\) is weighted or not.
The normalized thresholds divide by the in-, out-, or total degree
(or strength, where the network is weighted) that matches direction.
Nodes with no ties in that direction that adopt have a threshold of 0.
Seeds have a missing threshold,
since their adoption says nothing about their exposure,
and so they do not bring down an average threshold.
A node that is never active is out of the diffusion,
as in manynet::play_diffusion():
its ties count neither for nor against the exposure of its contacts,
and its own threshold, time, and exposure are missing.
Nodes that never adopt have an infinite threshold,
since their threshold was never reached.
lag = 0, direction = "out" reproduces
netdiffuseR::threshold(valued = TRUE), and lag = 1, direction = "in"
reproduces netdiffuseR::threshold(lags = 1, outgoing = FALSE, valued = TRUE),
except that {netdiffuseR} reports non-adopters as missing
and gives seeds a value where there is no lag,
and counts cumulative rather than current adopters.
By default, {netdiffuseR} ignores tie weights,
so the results differ from it on weighted networks.
node_by_adopt_recovery() measures the average length of time that nodes
that become infected remain infected in a compartmental model with recovery.
Infections that are not concluded by the end of the study period are
calculated as infinite.
node_exposure() calculates the number of infected/adopting nodes
to which each susceptible node is exposed.
It usually expects network data and
an index or mark (TRUE/FALSE) vector of those nodes which are currently infected,
but if a diff_model is supplied instead it will return
nodes exposure at \(t = 0\).
Nodes in the mark have an exposure of 0.
Other diffusion:
mark_diff,
measure_diffusion_infection,
measure_diffusion_net,
member_diffusion,
motif_exposure,
motif_hazard
Other measures:
measure_accuracy_net,
measure_accuracy_node,
measure_assort_net,
measure_assort_node,
measure_breadth,
measure_broker_node,
measure_brokerage,
measure_central_between,
measure_central_close,
measure_central_degree,
measure_central_eigen,
measure_central_tie_between,
measure_central_tie_close,
measure_central_tie_degree,
measure_central_tie_eigen,
measure_closure,
measure_closure_node,
measure_cohesion,
measure_core,
measure_diffusion_infection,
measure_diffusion_net,
measure_diverse_dispersion,
measure_diverse_net,
measure_diverse_node,
measure_diverse_tie,
measure_domain,
measure_features,
measure_fit,
measure_fragmentation,
measure_hierarchy,
measure_opinion,
measure_periods,
tie_by_width()
Other nodal:
mark_core,
mark_degree,
mark_diff,
mark_nodes,
mark_select_node,
measure_accuracy_node,
measure_assort_node,
measure_broker_node,
measure_brokerage,
measure_central_between,
measure_central_close,
measure_central_degree,
measure_central_eigen,
measure_closure_node,
measure_core,
measure_diverse_node,
measure_domain,
measure_opinion,
member_brokerage,
member_cliques,
member_community,
member_community_hier,
member_community_modular,
member_community_partition,
member_community_spread,
member_components,
member_core,
member_diffusion,
member_equivalence,
motif_accuracy_node,
motif_brokerage_node,
motif_clique,
motif_composition,
motif_exposure,
motif_node,
motif_path
smeg <- generate_smallworld(15, 0.025)
smeg_diff <- play_diffusion(smeg, recovery = 0.2)
if (requireNamespace("autograph", quietly = TRUE)) plot(smeg_diff)
# To measure when nodes adopted a diffusion/were infected
(times <- node_by_adopt_time(smeg_diff))
#> # Adoption time [0, Inf)
#> ▃▂▃▂
#> V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13
#> 1 0 1 1 2 2 3 3 4 4 4 3 3 2
#> # ... and 2 more values from this nodeset. Use `print_all(...)` to print all values.
# To infer nodes' thresholds
node_by_adopt_threshold(smeg_diff)
#> # Adoption threshold, normalized [0, 1]
#> ▄▁▂▁▁▄
#> V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13
#> 1 NA 0.25 0.2 0.5 0.5 0.333 0.25 0.5 0.5 0.5 0.25 0.333 0.5
#> # ... and 2 more values from this nodeset. Use `print_all(...)` to print all values.
# To measure how long each node remains infected for
node_by_adopt_recovery(smeg_diff)
#> # Recovery time [0, Inf)
#> ▆▁▁▁▁▁▁
#> V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13
#> 1 Inf 3 2 Inf 3 2 3 5 8 3 3 3 3
#> # ... and 2 more values from this nodeset. Use `print_all(...)` to print all values.
# To measure how much exposure nodes have to a given mark
node_by_adopt_exposure(smeg, mark = c(1,3))
#> # Exposure [0, Inf)
#> ▆▂▁▂
#> V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13
#> 1 0 2 0 1 1 0 0 0 0 0 0 0 0
#> # ... and 2 more values from this nodeset. Use `print_all(...)` to print all values.
node_by_adopt_exposure(smeg_diff)
#> # Exposure [0, Inf)
#> ▆▁▁▁▃
#> V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13
#> 1 0 1 1 0 0 0 0 0 0 0 0 0 0
#> # ... and 2 more values from this nodeset. Use `print_all(...)` to print all values.