Bergm: Bayesian Exponential Random Graphs in R
In this paper we describe the main featuress of the Bergm package for the open-source R software which provides a comprehensive framework for Bayesian analysis for exponential random graph models: tools for parameter estimation, model selection and goodness-of-fit diagnostics. We illustrate the capabilities of this package describing the algorithms through a tutorial analysis of two well-known network datasets.
💡 Research Summary
The paper presents Bergm, an R package that brings a full Bayesian framework to the analysis of exponential random graph models (ERGMs). Traditional ERGM inference relies on maximum‑likelihood estimation, which often suffers from convergence problems, sensitivity to starting values, and a lack of principled model‑selection criteria. By adopting a Bayesian perspective, Bergm allows researchers to incorporate prior knowledge, quantify posterior uncertainty, and compare competing network specifications using Bayes factors.
The methodological core of the package is the exchange algorithm, a variant of Metropolis–Hastings that sidesteps the intractable normalising constant of the ERGM likelihood. For each proposed parameter vector, the algorithm simultaneously generates an auxiliary network from the ERGM defined by that vector; the ratio of the two unnormalised likelihoods cancels the unknown constant, yielding a valid acceptance probability. Bergm implements this algorithm on top of the statnet infrastructure, reusing the network object format and the simulation engine of the ergm package. Users can specify arbitrary sufficient statistics (e.g., edges, gwesp, nodematch) and choose normal or custom prior distributions.
Beyond estimation, Bergm provides tools for Bayesian model selection. The package computes approximations to the marginal likelihood using the harmonic mean estimator and, optionally, bridge sampling. These estimates are combined into Bayes factors that enable a quantitative comparison of nested or non‑nested ERGM specifications. The authors also discuss practical strategies for stabilising marginal‑likelihood estimates, such as prior scaling and adaptive proposal tuning.
Goodness‑of‑fit assessment is carried out through posterior predictive checks. After drawing posterior samples, Bergm repeatedly simulates networks from the fitted model and compares key network statistics—degree distribution, triad census, geodesic distances—to those observed in the data. Visual diagnostics are produced via integration with the bayesplot and coda packages, allowing users to inspect trace plots, autocorrelation, and effective sample size for each parameter.
The package is designed for modern computational environments. It supports parallel execution of multiple MCMC chains using the parallel package, which dramatically reduces wall‑clock time for large‑scale analyses and facilitates convergence diagnostics across chains. Results are returned as mcmc.list objects, making downstream analysis with standard Bayesian tools straightforward.
The authors illustrate Bergm’s capabilities with two canonical datasets. The first example revisits the Florentine families marriage network. Starting from a simple edge‑only model, they incrementally add geometrically weighted edgewise shared partner (gwesp) terms and a nodematch effect for family affiliation. Posterior samples reveal credible intervals for each coefficient, and Bayes‑factor comparison selects the model that balances parsimony with fit. Posterior predictive plots show that the selected model reproduces the observed clustering coefficient and degree heterogeneity.
The second example analyses Zachary’s karate club network, a classic case of social division. Here the authors explore models that include degree, triangle, and nodematch(gender) statistics. They run four parallel chains for 50,000 iterations each, discard burn‑in, and assess convergence with Gelman‑Rubin diagnostics. The Bayes factor favours a model that incorporates both triangle and nodematch effects, reflecting the importance of triadic closure and homophily in the club’s split. Posterior predictive checks confirm that the chosen model captures the observed community structure and path‑length distribution.
In the discussion, the authors acknowledge the computational burden of the exchange algorithm, especially for high‑dimensional parameter spaces or very large networks. They suggest possible extensions such as variational Bayes approximations, adaptive tempering, and more efficient auxiliary‑network simulators. Future work also includes automated prior elicitation, integration with dynamic network models, and a graphical user interface to broaden accessibility.
Overall, the paper demonstrates that Bergm delivers a coherent, reproducible, and statistically rigorous workflow for Bayesian ERGM analysis. By unifying estimation, model selection, and diagnostic tools within a single R package, it lowers the barrier for researchers in sociology, epidemiology, and related fields to adopt Bayesian network modelling, thereby advancing the reliability and interpretability of network‑based inference.
Comments & Academic Discussion
Loading comments...
Leave a Comment