# Exponential family random graph models

Exponential family random graph models (ERGMs) are a set of statistical models used to study the structure and patterns within networks, such as those in social, organizational, or scientific contexts. They analyze how connections (edges) form between individuals or entities (nodes) by modeling the likelihood of network features, like clustering or centrality, across diverse examples including knowledge networks, organizational networks, colleague networks, social media networks, networks of scientific collaboration, and more. Part of the exponential family of distributions, ERGMs help researchers understand and predict network behavior in fields ranging from sociology to data science.
Part of a series on :
Network science :
Theory :
Graph
Complex network
Contagion
Small-world
Scale-free
Community structure
Percolation
Evolution
Controllability
Graph drawing
Social capital
Link analysis
Optimization
Reciprocity
Closure
Homophily
Transitivity
Preferential attachment
Balance theory
Network effect
Social influence :
Network types :
Informational (computing)
Telecommunication
Transport
Social
Scientific collaboration
Biological
Artificial neural
Interdependent
Semantic
Spatial
Dependency
Flow
on-Chip :
Graphs :
MetricsAlgorithms :
Centrality
Degree
Motif
Clustering
Degree distribution
Assortativity
Distance
Modularity
Efficiency :
Models :
ListsCategories :
Topics
Software
Network scientists
Category:Network theory
Category:Graph theory :
vte :

## Background

Many metrics exist to describe the structural features of an observed network such as the density, centrality, or assortativity. However, these metrics describe the observed network which is only one instance of a large number of possible alternative networks. This set of alternative networks may have similar or dissimilar structural features. To support statistical inference on the processes influencing the formation of network structure, a statistical model should consider the set of all possible alternative networks weighted on their similarity to an observed network. However because network data is inherently relational, it violates the assumptions of independence and identical distribution of standard statistical models like linear regression. Alternative statistical models should reflect the uncertainty associated with a given observation, permit inference about the relative frequency about network substructures of theoretical interest, disambiguating the influence of confounding processes, efficiently representing complex structures, and linking local-level processes to global-level properties. Degree-preserving randomization, for example, is a specific way in which an observed network could be considered in terms of multiple alternative networks.

## Definition

The Exponential family is a broad family of models for covering many types of data, not just networks. An ERGM is a model from this family which describes networks.
Formally a random graph $Y\in {\mathcal {Y}}$ consists of a set of $n$ nodes and a collection of tie variables $\{Y_{ij}:i=1,\dots ,n;j=1,\dots ,n\}$, indexed by pairs of nodes $ij$, where $Y_{ij}=1$ if the nodes $(i,j)$ are connected by an edge and $Y_{ij}=0$ otherwise. A pair of nodes $ij$ is called a dyad and a dyad is an edge if $Y_{ij}=1$.
The basic assumption of these models is that the structure in an observed graph $y$ can be explained by a given vector of sufficient statistics $s(y)$ which are a function of the observed network and, in some cases, nodal attributes. This way, it is possible to describe any kind of dependence between the undyadic variables:
$P(Y=y|\theta )={\frac {\exp(\theta ^{T}s(y))}{c(\theta )}},\quad \forall y\in {\mathcal {Y}}$
where $\theta$ is a vector of model parameters associated with $s(y)$ and $c(\theta )=\sum _{y'\in {\mathcal {Y}}}\exp(\theta ^{T}s(y'))$ is a normalising constant.
These models represent a probability distribution on each possible network on $n$ nodes. However, the size of the set of possible networks for an undirected network (simple graph) of size $n$ is $2^{n(n-1)/2}$. Because the number of possible networks in the set vastly outnumbers the number of parameters which can constrain the model, the ideal probability distribution is the one which maximizes the Gibbs entropy.

## Example

Let $V=\{1,2,3\}$ be a set of three nodes and let ${\mathcal {Y}}$ be the set of all undirected, loopless graphs on $V$. Loopless implies that for all $i=1,2,3$ it is $Y_{ii}=0$ and undirected implies that for all $i,j=1,2,3$ it is $Y_{ij}=Y_{ji}$, so that there are three binary tie variables ($Y_{12},Y_{13},Y_{23}$) and $2^{3}=8$ different graphs in this example.
Define a two-dimensional vector of statistics by $s(y)=[s_{1}(y),s_{2}(y)]^{T}$, where $s_{1}(y)=edges(y)$ is defined to be the number of edges in the graph $y$ and $s_{2}(y)=triangles(y)$ is defined to be the number of closed triangles in $y$. Finally, let the parameter vector be defined by $\theta =(\theta _{1},\theta _{2})^{T}=(-\ln 2,\ln 3)^{T}$, so that the probability of every graph $y\in {\mathcal {Y}}$ in this example is given by:
$P(Y=y|\theta )={\frac {\exp(-\ln 2\cdot edges(y)+\ln 3\cdot triangles(y))}{c(\theta )}}$
We note that in this example, there are just four graph isomorphism classes: the graph with zero edges, three graphs with exactly one edge, three graphs with exactly two edges, and the graph with three edges. Since isomorphic graphs have the same number of edges and the same number of triangles, they also have the same probability in this example ERGM. For a representative $y$ of each isomorphism class, we first compute the term $x(y)=\exp(-\ln 2\cdot edges(y)+\ln 3\cdot triangles(y))$, which is proportional to the probability of $y$ (up to the normalizing constant $c(\theta )$).
If $y$ is the graph with zero edges, then it is $edges(y)=0$ and $triangles(y)=0$, so that
$x(y)=\exp(-\ln 2\cdot 0+\ln 3\cdot 0)=\exp(0)=1.$
If $y$ is a graph with exactly one edge, then it is $edges(y)=1$ and $triangles(y)=0$, so that
$x(y)=\exp(-\ln 2\cdot 1+\ln 3\cdot 0)={\frac {\exp(0)}{\exp(\ln 2)}}={\frac {1}{2}}.$
If $y$ is a graph with exactly two edges, then it is $edges(y)=2$ and $triangles(y)=0$, so that
$x(y)=\exp(-\ln 2\cdot 2+\ln 3\cdot 0)={\frac {\exp(0)}{\exp(\ln 2)^{2}}}={\frac {1}{4}}.$
If $y$ is the graph with exactly three edges, then it is $edges(y)=3$ and $triangles(y)=1$, so that
$x(y)=\exp(-\ln 2\cdot 3+\ln 3\cdot 1)={\frac {\exp(\ln 3)}{\exp(\ln 2)^{3}}}={\frac {3}{8}}.$
The normalizing constant is computed by summing $x(y)$ over all eight different graphs $y\in {\mathcal {Y}}$. This yields:
$c(\theta )=1+3\cdot {\frac {1}{2}}+3\cdot {\frac {1}{4}}+{\frac {3}{8}}={\frac {29}{8}}.$
Finally, the probability of every graph $y\in {\mathcal {Y}}$ is given by $P(Y=y|\theta )={\frac {x(y)}{c(\theta )}}$. Explicitly, we get that the graph with zero edges has probability ${\frac {8}{29}}$, every graph with exactly one edge has probability ${\frac {4}{29}}$, every graph with exactly two edges has probability ${\frac {2}{29}}$, and the graph with exactly three edges has probability ${\frac {3}{29}}$ in this example.
Intuitively, the structure of graph probabilities in this ERGM example are consistent with typical patterns of social or other networks. The negative parameter ($\theta _{1}=-\ln 2$) associated with the number of edges implies that - all other things being equal - networks with fewer edges have a higher probability than networks with more edges. This is consistent with the sparsity that is often found in empirical networks, namely that the empirical number of edges typically grows at a slower rate than the maximally possible number of edges. The positive parameter ($\theta _{2}=\ln 3$) associated with the number of closed triangles implies that - all other things being equal - networks with more triangles have a higher probability than networks with fewer triangles. This is consistent with a tendency for triadic closure that is often found in certain types of social networks. Compare these patterns with the graph probabilities computed above. The addition of every edge divides the probability by two. However, when going from a graph with two edges to the graph with three edges, the number of triangles increases by one - which additionally multiplies the probability by three.
We note that the explicit calculation of all graph probabilities is only possible since there are so few different graphs in this example. Since the number of different graphs scales exponentially in the number of tie variables - which in turn scales quadratic in the number of nodes -, computing the normalizing constant is in general computationally intractable, already for a moderate number of nodes.

## Sampling from an ERGM

Exact sampling from a given ERGM is computationally intractable in general since computing the normalizing constant requires summation over all $y\in {\mathcal {Y}}$. Efficient approximate sampling from an ERGM can be done via Markov chains and is applied in current methods to approximate expected values and to estimate ERGM parameters. Informally, given an ERGM on a set of graphs ${\mathcal {Y}}$ with probability mass function $P(Y=y|\theta )={\frac {\exp(\theta ^{T}s(y))}{c(\theta )}}$, one selects an initial graph $y^{(0)}\in {\mathcal {Y}}$ (which might be arbitrarily, or randomly, chosen or might represent an observed network) and implicitly defines transition probabilities (or jump probabilities) $\pi (y,y')=P(Y^{(t+1)}=y'|Y^{(t)}=y)$, which are the conditional probabilities that the Markov chain is on graph $y'$ after Step $t+1$, given that it is on graph $y$ after Step $t$. The transition probabilities do not depend on the graphs in earlier steps ($y^{(0)},\dots ,y^{(t-1)}$), which is a defining property of Markov chains, and they do not depend on $t$, that is, the Markov chain is time-homogeneous. The goal is to define the transition probabilities such that for all $y\in {\mathcal {Y}}$ it is
$\lim _{t\to \infty }P(Y^{(t)}=y)={\frac {\exp(\theta ^{T}s(y))}{c(\theta )}},$
independent of the initial graph $y^{(0)}$. If this is achieved, one can run the Markov chain for a large number of steps and then returns the current graph as a random sample from the given ERGM. The probability to return a graph $y\in {\mathcal {Y}}$ after a finite but large number of update steps is approximately the probability defined by the ERGM.
Current methods for sampling from ERGMs with Markov chains usually define an update step by two sub-steps: first, randomly select a candidate $y'$ in a neighborhood of the current graph $y$ and, second, to accept $y'$ with a probability that depends on the probability ratio of the current graph $y$ and the candidate $y'$. (If the candidate is not accepted, the Markov chain remains on the current graph $y$.) If the set of graphs ${\mathcal {Y}}$ is unconstrained (i.e., contains any combination of values on the binary tie variables), a simple method for candidate selection is to choose one tie variable $y_{ij}$ uniformly at random and to define the candidate by flipping this single variable (i.e., to set $y'_{ij}=1-y_{ij}$; all other variables take the same value as in $y$). A common way to define the acceptance probability is to accept $y'$ with the conditional probability
$P(Y=y'|Y=y'\vee Y=y)={\frac {P(Y=y')}{P(Y=y')+P(Y=y)}},$
where the graph probabilities are defined by the ERGM. Crucially, the normalizing constant $c(\theta )$ cancels out in this fraction, so that the acceptance probabilities can be computed efficiently.