ERGM.jl
Fit probability models for a binary network observed on a fixed set of actors. ERGM.jl combines structural statistics and actor or dyad covariates, estimates their coefficients, and simulates networks for model checking.
| First analysis | Learn the model or data | Reference and detail |
|---|---|---|
| Fit and check a first model | Choose an estimator | Browse model terms |
Estimation supports loop-free, one-mode binary networks. Bipartite ERGMs, and curved terms other than gwesp/gwdegree, are not implemented. As in R, ergm fits a dyad-independent formula by MPLE (then the exact MLE) and a dyad-dependent one by MCMC-MLE, whose convergence diagnostics are part of the result; MPLE of a dyad-dependent formula (method=:mple) is a conditional approximation. Missing dyads require the estimator-specific policies described in the estimation guide.
Installation
Use Julia 1.12 or newer and the shared workspace installation guide. These development packages are not yet registered; the guide prepares the required sibling checkouts and a Julia environment for the examples.
Quick Start
Start with a dyad-independent baseline for the bundled Florentine marriage network:
using NetworkCore, ERGM, Random
net = load_dataset(:florentine_marriage)
fit = fit_ergm(net, [Edges(), NodeCov(:wealth)]; method=:mple)
display(fit)
draws = simulate_ergm(fit; n_sim=3, rng=Xoshiro(42))
println(network_density.(draws))Here the wealth term associates the sum of two families’ wealth with their conditional log-odds of a marriage tie. Dyad independence makes this MPLE objective a likelihood. Three draws illustrate simulation; they are too few for a goodness-of-fit assessment. Dependence terms such as triangles change both the model and the estimation problem.
Choosing Terms
| Use Case | Recommended Terms |
|---|---|
| Baseline density | Edges |
| Reciprocity (directed) | Mutual |
| Triadic closure | Triangle, GWESP |
| Two-path prevalence | GWDSP |
| Degree distribution | Kstar, GWDegree (undirected); OStar, IStar, GWIDegree, GWODegree (directed) |
| Specific degree counts (isolates, ...) | Degree, IDegree, ODegree |
| Attribute homophily | NodeMatch, AbsDiff |
| Group mixing structure | NodeMix |
| Attribute main effects | NodeCov, NodeFactor |
| Dyadic covariates | EdgeCov |
Documentation
- Getting Started
- Model Terms
- Model Estimation
- Network Simulation
- Goodness of Fit and Diagnostics
- Coming from R
- Types API Reference
- Terms API Reference
- Estimation API Reference
- Extension API
Theoretical Background
The ERGM Framework
An ERGM specifies the probability of a network $y$ on $n$ nodes as:
\[P_\theta(Y = y) = \frac{\exp\left(\theta^\top g(y)\right)}{c(\theta)}, \quad c(\theta) = \sum_{y' \in \mathcal{Y}} \exp\left(\theta^\top g(y')\right)\]
The normalizing constant $c(\theta)$ sums over all possible networks, making exact computation intractable for all but very small networks. This motivates the two estimation approaches:
- MPLE approximates the likelihood by treating dyads as conditionally independent, reducing the problem to logistic regression
- MCMLE uses MCMC sampling to approximate the ratio of normalizing constants, iterating via Newton-Raphson until convergence
Change Statistics
The change statistic $\delta_g(y)_{ij}$ measures how statistic $g$ changes when edge $(i,j)$ is toggled:
\[\delta_g(y)_{ij} = g(y^+_{ij}) - g(y^-_{ij})\]
Change statistics are central to both estimation (MPLE uses them as features) and simulation (MCMC acceptance probabilities depend on them).
References
Hunter, D.R., Handcock, M.S., Butts, C.T., Goodreau, S.M., Morris, M. (2008). ergm: A Package to Fit, Simulate and Diagnose Exponential-Family Models for Networks. Journal of Statistical Software, 24(3), 1-29.
Robins, G., Pattison, P., Kalish, Y., Lusher, D. (2007). An introduction to exponential random graph (p) models for social networks. *Social Networks, 29(2), 173-191.
Snijders, T.A.B. (2002). Markov chain Monte Carlo estimation of exponential random graph models. Journal of Social Structure, 3(2), 1-40.
Strauss, D., Ikeda, M. (1990). Pseudolikelihood estimation for social networks. Journal of the American Statistical Association, 85(409), 204-212.
Frank, O., Strauss, D. (1986). Markov graphs. Journal of the American Statistical Association, 81(395), 832-842.
Citation
If you use ERGM.jl in your work, please cite it using the entry in CITATION.bib:
@misc{SNWJERGMJL,
author = {Santoni, Simone},
title = {ERGM.jl: Exponential Random Graph Models for Julia},
year = {2026},
url = {https://github.com/statistical-network-analysis-with-Julia/ERGM.jl},
note = {Homepage: https://statistical-network-analysis-with-Julia.github.io/ERGM.jl; GitHub: https://github.com/statistical-network-analysis-with-Julia}
}