This package provides an R implementation of the netinf algorithm created by @gomez2010inferring (see here for more information and the original C++ implementation). Given a set of events that spread between a set of nodes the algorithm infers the most likely stable diffusion network that is underlying the diffusion process.
The package can be installed from CRAN:
install.packages("NetworkInference")
The latest development version can be installed from github:
#install.packages(devtools)
devtools::install_github('desmarais-lab/NetworkInference')
To get started, get your data into the cascades
format required by the netinf
function:
library(NetworkInference)
# Simulate random cascade data
df <- simulate_rnd_cascades(50, n_node = 20)
# Cast data into `cascades` object
## From long format
cascades <- as_cascade_long(df)
## From wide format
df_matrix <- as.matrix(cascades) ### Create example matrix
cascades <- as_cascade_wide(df_matrix)
Then fit the model:
result <- netinf(cascades, quiet = TRUE, p_value_cutoff = 0.05)
head(result)
origin_node | destination_node | improvement | p_value |
---|---|---|---|
15 | 17 | 299.5 | 2.817e-06 |
8 | 11 | 292.4 | 7.268e-06 |
8 | 10 | 290.6 | 7.356e-06 |
10 | 13 | 254 | 4.629e-05 |
5 | 4 | 253.6 | 4.677e-05 |
18 | 16 | 249.8 | 4.673e-05 |