We provide a Python package called mechanistic_net_abc
that contains implementations of mechanistic models to describe the formation of networks. We focus on models of mixture of mechanisms that combine different node-level mechanisms. Models are fitted using Approximate Bayesian Computation (ABC) techniques. To improve ABC inference we propose a summary statistic selection method using multi-output random forests. This package also provides codes for reproducibility of the analysis carried in our manuscript Uncovering mechanisms of network formation by L. Raynal and J.-P. Onnela.
This project focuses on models of mixture of mechanisms to understand network formation from the observation of a single graph. Inference is performed using ABC methods.
Our objectives consists in:
- identifying the mechanisms explaining the formation of a network, and in which proportion each mechanism intervene;
- proposing a summary statistic selection technique for improve ABC parameter inference.
Install with pip
from a terminal
pip install git+https://github.com/onnela-lab/mechanistic-net-abc.git
Important: Before running the different examples please edit settings.py
to indicate a valid working directory for each studied example. Figures, simulated data and results will be stored in these directories.
The mechanistic_net_abc
folder contains the package, made of the following modules:
abc.py
contains an implementation of the replenishment sequential Monte Carlo ABC (SMC-ABC) algorithm proposed by Drovandi and Pettitt, (2011).data_generation.py
to generate individual network data (summarized) from a model of mixture of mechanisms (data_indiv_simulation
) or a reference table (data_ref_table_simulation
).data_reading.py
: read real data.mechanisms.py
provides various mechanisms for network formation. Examples are the functionsnode_addition
,preferential_attachment_growth
,neg_preferential_attachment_growth
,random_attachment_growth
,random_node_deletion
,random_edge_deletion
,random_edge_rewiring
,triadic_closure
,triadic_closure_without_rewiring
ortriangle_formation_node_addition
.models.py
implements the model of mixture of mechanisms to generate networks (see functionmixture_model_simulation
).summaries.py
to compute summary statistics of undirected networks usingnetworkx
.summary_selection.py
implements our recursive selection technique based on multi-output random forests.utility.py
: various utility functions.
The folder 1-PA_one_noise
focuses on the first simulated example of our paper where we identify preferential attachment from one noise mechanism that is random attachment.
The folder 2-PA_two_noises
considers the previous example where we add an additional noise mechanism, triangle formation.
The folder 3-PA_RA_TF_mixture
contains a simulated example where three mechanisms are relevant and their weights and parameters are inferred.
The folder 4-household_analysis
is dedicated to the study of a real household network.
We provide three simulated studies that can show you how to formulate a model of mixture of mechanisms, generate data from this model, select summaries with our random forest-based proposal and infer model parameters with ABC. Codes are ready to launch in the folders 1-PA_one_noise
, 2-PA_two_noises
and 3-PA_RA_TF_mixture
.
An empirical household network is also studied. The data contains 710 nodes that are households with edges representing contacts between them. We propose a mixture model of four mechanisms to understand its formation and the impact of these mechanisms. Full analysis can be replicated from codes in the 4-household_analysis
folder.
- Louis Raynal - Harvard University
- Jukka-Pekka Onnela - Harvard University