spreadr {spreadr} | R Documentation |
Simulate spreading activation in a network
Description
Simulate spreading activation in a network
Usage
spreadr(
network,
start_run,
retention = 0.5,
time = 10,
threshold_to_stop = NULL,
decay = 0,
suppress = 0,
include_t0 = FALSE,
create_names = TRUE,
never_stop = FALSE
)
Arguments
network |
Adjacency matrix or
|
start_run |
Non-empty |
retention |
Number from 0 to 1 (inclusive) or a numeric vector of such
numbers of length equals number of nodes in the network. This represents
the proportion of activation that remains in the node (not spread) at each
time step. Then, |
time |
Positive non-zero integer, or |
threshold_to_stop |
Number or |
decay |
Number from 0 to 1 (inclusive) representing the proportion of activation that is lost at each time step. |
suppress |
Number representing the maximum amount of activation in a node for it to be set to 0, at each time step. |
include_t0 |
Boolean flag indicating if activation at |
create_names |
Boolean flag indicating if nodes should be automatically
named ( |
never_stop |
Boolean flag indicating if the simulation should be stopped if there have been too many iterations (so that there might be an infinite loop). |
Details
At least one of parameters time
or threshold_to_stop
must be non-NULL
. If both are non-NULL
, the simulation stops
at the earliest time possible.
The simulation iterates like so: for every i
in [0, time]
,
Spread activation from node to node
Decay the activation at each node by the proportion specified by
decay
Set the activation at nodes with activation less than
suppress
to0
Add the activations in
start_run
withtime = i
to their corresponding nodesSave the activations at each node for output
Check the terminating conditions
time
andthreshold_to_stop
. If any are satisfied, terminate the simulation.
Value
A data.frame
with node, activation
and time columns representing the spread of activation in the network
over time.
Examples
# make an adjacency matrix and randomly fill some cells with 1s
mat <- matrix(sample(c(0,1), 100, replace=TRUE), 10, 10)
diag(mat) <- 0 # remove self-loops
initial_df <- data.frame(node=1, activation=20, stringsAsFactors=FALSE)
results <- spreadr(mat, initial_df)
head(results, 10)
tail(results, 10)