Bayesian analysis for exponential random graph models using advanced computational algorithms: the approximate exchange algorithm with adaptive direction sampling (optionally adaptive, delayed-acceptance and parallel), calibrated pseudo-posteriors, Bayesian data augmentation for missing network data, and Bayesian goodness-of-fit diagnostics. More information can be found at: < https://acaimo.github.io/Bergm/>.
Bergm provides a comprehensive framework for Bayesian parameter estimation and model selection for exponential random graph models using advanced computational algorithms. It can also supply graphical Bayesian goodness-of-fit procedures that address the issue of model adequacy and missing data imputation.
Bergm 6 is a rewrite of the computational core that keeps the Bergm 5 interface
(same functions, arguments and returned elements) while making every function
faster and more flexible. See NEWS.md for the full list.
bergmC, ergmAPL, evidenceCJ, evidencePP) run their MCMC and
pseudolikelihood evaluations in compiled code; bgof monitors
goodness-of-fit statistics inside the sampler.cores), and a
Newton-type stochastic approximation for the posterior mode in bergmC.gwesp(fixed = FALSE)), one-parameter
models, user-defined priors (log.prior), network proposals via ...,
reusable pseudolikelihood adjustments (apl =), posterior predictive
simulation (simulate()), per-chain output with R-hat, and coef(),
vcov(), as.mcmc() methods.Wall-clock time on a 2-core machine (ergm 4.12.0), average of two runs; "ESS/s
gain" compares effective samples per second for the worst-mixing parameter.
Full table, settings and validation against Bergm 5 in benchmarks/ (in the
source repository).
| Function, data, (Bergm 6 option) | Bergm 5 | Bergm 6 | ESS/s gain |
|---|---|---|---|
bergm(), Florentine |
9.4 s | 3.6 s | 2.7x |
bergm(), Lazega |
45.4 s | 31.9 s | 1.4x |
bergm(), Lazega, (delayed acceptance) |
45.4 s | 18.2 s | 1.9x |
bergm(), Faux Mesa High, (delayed acceptance) |
44.2 s | 19.1 s | 2.7x |
bergmM(), Florentine with missing nodes |
62.2 s | 5.4 s | 10.0x |
bergmC(), Florentine |
17.9 s | 1.0 s | 14.8x |
bergmC(), Lazega |
33.1 s | 6.0 s | 5.1x |
evidencePP(), Florentine |
18.1 s | 2.2 s | 8.1x |
evidencePP(), Lazega |
77.2 s | 13.3 s | 5.8x |
bgof(), Florentine |
3.9 s | 0.2 s | |
bgof(), Lazega |
7.5 s | 2.0 s |
library(Bergm)
data(florentine)
# Curved ERGM, delayed acceptance (default) and 4 workers
data(lazega)
fit2 <- bergm(lazega ~ edges + nodematch("Office") + gwesp(0.5, fixed = FALSE),
burn.in = 200, main.iters = 2000, aux.iters = 3000,
cores = 4, seed = 1)
# Model selection
a1 <- ergmAPL(flomarriage ~ edges + kstar(2))
a2 <- ergmAPL(flomarriage ~ edges + triangle)
evidencePP(flomarriage ~ edges + kstar(2), apl = a1)$log.evidence -
evidencePP(flomarriage ~ edges + triangle, apl = a2)$log.evidence
# Goodness of fit and posterior predictive networks
bgof(fit, sample.size = 100, aux.iters = 5000)
nets <- simulate(fit, nsim = 10)
Caimo, A., Bouranis, L., Krause, R., and Friel, N. (2022). Statistical Network Analysis with Bergm. Journal of Statistical Software, 104(1), 1–23. doi: https://doi.org/10.18637/jss.v104.i01.