API reference#
Fitting and simulating#
|
Fit an exponential-family random graph model. |
|
Simulate networks from an ERGM, starting from |
|
Statistics of a network, like R's |
|
Tuning parameters of the MCMC and of the Monte Carlo MLE. |
Several networks, and networks over time#
|
Several networks to model jointly, as R's |
|
A series of networks on the same vertices, as R's |
|
Fit a temporal ERGM to a series of networks by conditional maximum likelihood, as R's |
|
A temporal ERGM fitted by tergm's equilibrium generalized method of moments ( |
|
Simulate a network forward in time from a temporal ERGM, as R's tergm does with |
|
A network simulated over time by |
Results#
|
A fitted ERGM, as returned by |
|
The table of coefficients of a fit, printed like R's |
|
A fit saved with |
Interpreting and reporting results#
|
Tie probabilities of every dyad of a network under a model, as R's |
|
Predicted tie probabilities of a model, one per dyad, as R's |
|
A table of fitted models side by side, as R's texreg. |
|
Coefficients, standard errors and fit statistics of several models, as R's texreg tables. |
|
A small table of numbers by name, printed like R's matrices; convert it with |
Checking and comparing models#
|
Goodness of fit of an ERGM, like R's |
|
Goodness-of-fit tables, by statistic. |
|
One statistic's observed values and simulated distribution. |
|
Goodness of fit network by network, for a model of several networks ( |
|
Goodness of fit by network ( |
|
One statistic of |
|
Summaries of the observed and fitted values and the Pearson residuals of each statistic over the networks (by group, with |
|
Diagnostics of the MCMC sample of the last Monte Carlo MLE iteration. |
|
Compare fitted models of the same network, like R's |
|
AIC, BIC and likelihood-ratio tests of fitted models. |
Terms#
Call the functions to build a formula (edges() + gwesp(0.5, fixed=True)),
or write it as a string. See the term reference for the
statistics.
|
Number of edges. |
|
Number of reciprocated pairs of ties (directed networks). |
|
Number of pairs with a tie in one direction only (directed networks); with |
|
Sum over ties of a dyadic covariate. |
|
Each vertex's out-degree, one statistic per vertex of |
|
Each vertex's in-degree, one statistic per vertex of |
|
Each vertex's degree, one statistic per vertex of |
|
Number of k-stars, for one or more k (undirected networks); with |
|
Number of in-k-stars: sets of k ties to the same vertex (directed networks); with |
|
Number of out-k-stars: sets of k ties from the same vertex (directed networks); with |
|
Number of vertices with degree exactly d, for one or more d (undirected networks). |
|
Number of vertices with in-degree exactly d, for one or more d (directed networks); |
|
Number of vertices with out-degree exactly d, for one or more d (directed networks); |
|
Number of vertices without ties (in either direction, if directed). |
|
Number of vertices with degree 2 or more (undirected networks), by value of |
|
Number of 2-paths: i -> j -> k with i != k if directed, kstar(2) if undirected. |
|
Geometrically weighted degree distribution (undirected networks). |
|
Geometrically weighted in-degree distribution (directed networks), by value of |
|
Geometrically weighted out-degree distribution (directed networks), by value of |
|
Number of triangles; in directed networks, transitive plus cyclic triples. |
|
Number of transitive triples i -> j -> k with i -> k (directed networks); |
|
Number of cyclic triples i -> j -> k -> i (directed networks); |
Number of transitive triads (directed networks): those with at least one transitive triple and no intransitive two-path, the types 030T, 120D, 120U and 300 of Davis and Leinhardt's (1972) triad census. |
|
|
Number of cycles of length k, for one or more k: 3 or more in undirected networks, 2 or more in directed ones (cycle(2) is mutual). |
|
Geometrically weighted edgewise shared partners. |
|
Geometrically weighted dyadwise shared partners: as gwesp, over all pairs of vertices, tied or not (ordered pairs if directed). |
|
Geometrically weighted non-edgewise shared partners: as gwesp, over the pairs of vertices without a tie; gwdsp minus gwesp. |
|
Number of ties with exactly d edgewise shared partners, for one or more d. |
|
Number of pairs of vertices with exactly d shared partners, for one or more d (ordered pairs if directed). |
|
Number of pairs of vertices without a tie with exactly d shared partners, for one or more d. |
|
Number of ties between vertices with the same value of |
|
Number of ties for each mixing type: each pair of levels of |
|
Number of tie endpoints at each level of |
|
Number of ties received by vertices at each level of |
|
Number of ties sent by vertices at each level of |
|
Sum over ties of the endpoints' values of the numeric |
|
Sum over ties of the receiver's value of the numeric |
|
Sum over ties of the sender's value of the numeric |
|
Sum over ties of the absolute difference in the numeric |
|
For each distinct nonzero absolute difference of the numeric |
|
The density: the number of edges over the number of dyads. |
|
The mean degree: twice the number of edges over the number of vertices (the number of edges, if directed). |
|
A dyadic covariate by dyad state, in directed networks: its sum over mutual dyads ( |
|
The Hamming distance to a reference network |
|
Sum over ties of a covariate of the mixing type of their vertices: the entry of |
|
The cells of a mixing matrix, as ergm's mm(): |
|
Sum over ties of a function of the difference of the vertices' values of |
|
Number of ties whose vertices' values of |
|
Sum over vertices of the range of |
|
Sum over vertices of the range of |
|
Sum over vertices of the range of |
|
Sum over vertices of the number of distinct values of |
|
Sum over vertices of the number of distinct values of |
|
Sum over vertices of the number of distinct values of |
|
Number of vertices with degree in [from, to), for each pair (undirected networks); |
|
Number of vertices with in-degree in [from, to) (directed networks), as |
|
Number of vertices with out-degree in [from, to) (directed networks), as |
Sum over vertices of their degree to the power 3/2 (undirected networks). |
|
Sum over vertices of their in-degree to the power 3/2 (directed networks; |
|
Sum over vertices of their out-degree to the power 3/2 (directed networks; |
|
|
Sum over vertices of their ties beyond the first (undirected networks), by value of |
Number of ties whose two vertices have no other tie (undirected networks). |
|
|
Alternating k-stars (Snijders et al. 2006) with weight |
|
The triad census: the number of triads of each type of Davis and Leinhardt (1972), by default all but the empty one (directed networks: types 012 to 300, or their codes 1 to 15; undirected networks: triads with 1, 2 or 3 ties). |
|
Number of balanced triads: types 102 and 300 (undirected networks: triads with 1 or 3 ties). |
Number of intransitive triads (directed networks): types 111D, 201, 111U, 021C and 030C of the triad census. |
|
Number of Simmelian triads (directed networks): complete triads, type 300. |
|
Number of near-Simmelian triads (directed networks): one tie short of complete, type 210. |
|
Number of ties in at least one Simmelian triad (directed networks). |
|
|
Number of ties i -> j with a two-path i -> k -> j (in undirected networks, ties with a shared partner); with |
|
Number of ties i -> j with a two-path j -> k -> i (in undirected networks, ties with a shared partner); |
|
Number of 3-trails: walks of three distinct ties (a triangle counts as three). |
Number of 2-stars minus three times the number of triangles (undirected networks). |
|
Number of triangles whose three pairs of vertices are neighbours in |
|
|
Number of mixed 2-stars i -> j -> k, i != k (directed networks): twopath. |
|
|
|
|
|
|
|
|
|
|
|
|
Bipartite terms#
For bipartite networks (bipartite= in ergm()): b1 terms are
about the first mode, b2 terms the second.
|
Number of k-stars centred on first-mode vertices, for one or more k; with |
|
Number of k-stars centred on second-mode vertices, for one or more k; with |
|
Number of first-mode vertices with degree exactly d, for one or more d, by value of |
|
Number of second-mode vertices with degree exactly d, for one or more d, by value of |
|
Geometrically weighted degree distribution of the first mode, by value of |
|
Geometrically weighted degree distribution of the second mode, by value of |
|
Number of first-mode vertices with degree 2 or more, by value of |
|
Number of second-mode vertices with degree 2 or more, by value of |
|
For each level of |
|
For each level of |
|
Sum over ties of the first-mode endpoint's value of the numeric |
|
Sum over ties of the second-mode endpoint's value of the numeric |
|
Number of 2-stars centred on second-mode vertices whose two first-mode ends have the same value of |
|
Number of 2-stars centred on first-mode vertices whose two second-mode ends have the same value of |
|
Number of pairs of first-mode vertices with exactly d shared partners, for one or more d. |
|
Number of pairs of second-mode vertices with exactly d shared partners, for one or more d. |
|
Geometrically weighted shared partner distribution of pairs of first-mode vertices. |
|
Geometrically weighted shared partner distribution of pairs of second-mode vertices. |
|
Number of first-mode vertices with degree in [from, to), as |
|
Number of second-mode vertices with degree in [from, to), as |
|
Number of first-mode vertices with degree at least d, for one or more d. |
|
Number of second-mode vertices with degree at least d, for one or more d. |
|
Each first-mode vertex's degree, one statistic per vertex of |
|
Each second-mode vertex's degree, one statistic per vertex of |
|
Number of k-stars centred on first-mode vertices whose second-mode ends all have the same value of |
|
Number of k-stars centred on second-mode vertices whose first-mode ends all have the same value of |
|
Number of two-stars centred on first-mode vertices, by the value of |
|
Number of two-stars centred on second-mode vertices, by the value of |
|
Sum over first-mode vertices of the range of |
|
Sum over second-mode vertices of the range of |
|
Sum over first-mode vertices of the number of distinct values of |
|
Sum over second-mode vertices of the number of distinct values of |
Operators#
|
Fix a term's coefficients, as ergm's offset(). |
|
Evaluate |
|
Evaluate |
|
Evaluate |
|
tergm's formation model: |
|
tergm's persistence model: |
|
tergm's dissolution model: |
|
tergm's cross-sectional model: |
|
tergm's change model: |
|
A geometrically weighted term whose decay is estimated, as ergm's |
Statistics of tie ages#
tergm’s durational statistics: targets of the EGMME and monitors of dynamic
simulations (see the user guide); in formula
strings, by their R names (mean.age…).
Sum over ties of their ages (tergm's |
|
|
Mean age of the ties, or of their logarithms with |
|
Number of ties with age in [from, to) (tergm's |
|
Sum over ties of a dyadic covariate times their age (tergm's |
|
For each level of |
Multilevel terms#
MPNet’s configurations of two-level networks; see the user guide.
|
Star2AX: 2-stars of an A-tie and an X-tie, the sum over A vertices of their A-degree times their X-degree. |
|
Star2BX: 2-stars of a B-tie and an X-tie, the sum over B vertices of their B-degree times their X-degree. |
|
AXS1A: alternating X-stars with one A-tie, the sum over A vertices of their A-degree times g(X-degree). |
|
AXS1B: alternating X-stars with one B-tie, the sum over B vertices of their B-degree times g(X-degree). |
|
AAS1X: alternating A-stars with one X-tie, the sum over A vertices of g(A-degree) times their X-degree. |
|
ABS1X: alternating B-stars with one X-tie, the sum over B vertices of g(B-degree) times their X-degree. |
|
AAAXS: alternating A-stars and alternating X-stars, the sum over A vertices of g(A-degree) g(X-degree). |
|
ABAXS: alternating B-stars and alternating X-stars, the sum over B vertices of g(B-degree) g(X-degree). |
|
TXAX: triangles of an A-tie and two X-ties to a common B vertex, the sum over A-ties of their endpoints' shared B partners. |
|
TXBX: triangles of a B-tie and two X-ties to a common A vertex. |
|
ATXAX: alternating TXAX triangles, the sum over A-ties of g(shared B partners), as gwesp with partners in B. |
|
ATXBX: alternating TXBX triangles, the sum over B-ties of g(shared A partners). |
|
L3XAX: three-paths of an X-tie, an A-tie and an X-tie, the sum over A-ties of the product of their endpoints' X-degrees (so closed paths, the TXAX triangles, count too, as Wang et al. say: "the TXAX configuration is also part of L3XAX"). |
|
L3XBX: three-paths of an X-tie, a B-tie and an X-tie, the sum over B-ties of the product of their endpoints' X-degrees. |
|
L3AXB: cross-level three-paths of an A-tie, an X-tie and a B-tie, the sum over X-ties of the A-degree of their A end times the B-degree of their B end. |
|
C4AXB: cross-level 4-cycles of an A-tie, a B-tie and the two X-ties that join their ends (alignment between the levels). |
|
EXTA: an A-triangle with an X-tie at one of its vertices, the sum over A vertices of their A-triangles times their X-degree. |
|
EXTB: a B-triangle with an X-tie at one of its vertices. |
|
ASAXASB: alternating A-stars and alternating B-stars joined by an X-tie, the sum over X-ties (a, b) of g(A-degree of a) g(B-degree of b). |
|
In2StarAX: sum over A vertices of in(v) x(v): an incoming A-tie with an X-tie. |
|
In2StarBX: sum over B vertices of in(v) x(v). |
|
Out2StarAX: sum over A vertices of out(v) x(v): an outgoing A-tie with an X-tie. |
|
Out2StarBX: sum over B vertices of out(v) x(v). |
|
AXS1Ain: alternating X-stars with one incoming A-tie, the sum over A vertices of in(v) g(x(v)). |
|
AXS1Bin: the sum over B vertices of in(v) g(x(v)). |
|
AXS1Aout: alternating X-stars with one outgoing A-tie, the sum over A vertices of out(v) g(x(v)). |
|
AXS1Bout: the sum over B vertices of out(v) g(x(v)). |
|
AAinS1X: alternating A-in-stars with one X-tie, the sum over A vertices of g(in(v)) x(v). |
|
ABinS1X: the sum over B vertices of g(in(v)) x(v). |
|
AAoutS1X: alternating A-out-stars with one X-tie, the sum over A vertices of g(out(v)) x(v). |
|
ABoutS1X: the sum over B vertices of g(out(v)) x(v). |
|
TXAXarc: over A-arcs, the number of B vertices X-tied to both ends. |
|
TXBXarc: over B-arcs, the number of A vertices X-tied to both ends. |
|
TXAXreciprocity: over reciprocated pairs of A-arcs, the number of B vertices X-tied to both. |
|
TXBXreciprocity: over reciprocated pairs of B-arcs, the number of A vertices X-tied to both. |
|
ATXAXarc: over A-arcs, g(the B vertices X-tied to both ends). |
|
ATXBXarc: over B-arcs, g(the A vertices X-tied to both ends). |
|
ATXAXreciprocity: over reciprocated pairs of A-arcs, g(the B vertices X-tied to both). |
|
ATXBXreciprocity: over reciprocated pairs of B-arcs, g(the A vertices X-tied to both). |
|
L3XAXreciprocity: over reciprocated pairs of A-arcs, the product of the ends' X-degrees. |
|
L3XBXreciprocity: over reciprocated pairs of B-arcs, the product of the ends' X-degrees. |
|
L3AXBin: over X-ties a -> b, in(a) in(b): both ends receive within their level. |
|
L3AXBout: over X-ties a -> b, out(a) out(b): both ends send within their level. |
|
L3AXBpath: over X-ties a -> b, in(a) out(b): a path from A through X into B. |
|
L3BXApath: over X-ties a -> b, out(a) in(b): a path from B through X into A. |
|
C4AXBentrainment: 4-cycles of an A-arc u -> v, a B-arc w -> z and the X-ties u -> w and v -> z: the arcs aligned. |
|
C4AXBexchange: 4-cycles of an A-arc u -> v, a B-arc w -> z and the X-ties u -> z and v -> w: the arcs opposed. |
|
C4AXBexchangeAreciprocity: 4-cycles of a reciprocated pair of A-arcs, a B-arc and two X-ties. |
|
C4AXBexchangeBreciprocity: 4-cycles of an A-arc, a reciprocated pair of B-arcs and two X-ties. |
|
C4AXBreciprocity: 4-cycles of reciprocated pairs of A- and B-arcs and two X-ties. |
|
AinASXAinBS: over X-ties a -> b, g(in(a)) g(in(b)): alternating in-stars at both ends. |
|
AoutASXAoutBS: over X-ties a -> b, g(out(a)) g(out(b)). |
|
AinASXAoutBS: over X-ties a -> b, g(in(a)) g(out(b)). |
|
AoutASXAinBS: over X-ties a -> b, g(out(a)) g(in(b)). |
Constraints#
Give constraints to ergm(), simulate() and gof() as strings
in R syntax, "bd(maxout=4) + blocks('level', levels2=2)". See the
user guide.
|
Constraints from a string in R syntax ( |
|
Bounds on degrees, as ergm's bd(): at most |
|
Fix the dyads of some mixing types of a vertex attribute, as ergm's blocks(): those whose toggle would change |
Preserve every vertex's degree (in- and out-degrees, if directed). |
|
Preserve every vertex's out-degree (directed networks). |
|
Preserve every vertex's in-degree (directed networks). |
|
Preserve the number of edges, as ergm's edges constraint. |
|
Preserve the degrees of the first mode's vertices (bipartite networks). |
|
Preserve the degrees of the second mode's vertices (bipartite networks). |
|
|
Fix some dyads at their observed value, as ergm's fixedas(): |
|
Fix every dyad but |
Fix the observed dyads: only those whose value is missing vary, as ergm's observed constraint (to simulate the missing ties). |
|
|
Allow ties only between vertices with the same value of |
|
Fix or free the dyads that dyad-independent terms count, as ergm's Dyads(): with |
Formulas#
|
Parse a formula string into terms. |
|
A sum of model terms. |
|
A model term: one or more network statistics. |
Errors#
The model could not be fitted: the simulated networks are very unlike the observed one, a sign that the model is degenerate or the starting values poor. |
|
The formula can't be parsed. |
|
A term whose statistic differs from what R's ergm computes for it, because ergmx follows ergm's documented definition. |
Datasets#
|
Load a bundled network. |
Names of the bundled networks. |
|
|
What a bundled network is, its source and its vertex attributes. |