NetworkInference: Quick Start Guide

Fridolin Linder



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:


The latest development version can be installed from github:


Quick start guide

To get started, get your data into the cascades format required by the netinf function:


# 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)
origin_node destination_node improvement p_value
14 4 346.5 3.099e-07
5 15 303.5 6.984e-06
8 9 301.3 2.838e-06
17 5 301.1 2.868e-06
12 10 295.8 7.161e-06
8 6 293.5 7.285e-06