API reference#

Fitting and simulating#

ergm(network, formula, *[, constraints, ...])

Fit an exponential-family random graph model.

simulate(network, formula, coef[, nsim, ...])

Simulate networks from an ERGM, starting from network.

summary_stats(network, formula, *[, bipartite])

Statistics of a network, like R's summary(net ~ formula).

Control([samplesize, interval, burnin, ...])

Tuning parameters of the MCMC and of the Monte Carlo MLE.

Several networks, and networks over time#

Networks(*networks[, bipartite])

Several networks to model jointly, as R's ergm.multi::Networks().

NetSeries(*networks[, times, bipartite, ...])

A series of networks on the same vertices, as R's tergm::NetSeries(), to model each transition conditional on the network before it.

tergm(networks, formula, *[, estimate, ...])

Fit a temporal ERGM to a series of networks by conditional maximum likelihood, as R's tergm(..., estimate="CMLE").

EgmmeFit(network, formula, model, names, ...)

A temporal ERGM fitted by tergm's equilibrium generalized method of moments (ergmx.tergm() with estimate="EGMME"): coefficients whose dynamic process has, at equilibrium, the target statistics.

simulate_dynamic(network, formula, coef[, ...])

Simulate a network forward in time from a temporal ERGM, as R's tergm does with simulate(..., dynamic=TRUE).

DynamicSimulation(start, edges, stats, ...)

A network simulated over time by ergmx.simulate_dynamic(): the starting network and the network after each time step.

Results#

ErgmFit(model, estimate, mple, control, seed)

A fitted ERGM, as returned by ergmx.ergm().

FitSummary(fit)

The table of coefficients of a fit, printed like R's summary(ergm).

load_fit(path)

A fit saved with fit.save(path) (ErgmFit.save()), ready to summarize, simulate, check and compare as before.

Interpreting and reporting results#

predict(network, formula, coef, *[, ...])

Tie probabilities of every dyad of a network under a model, as R's predict(net ~ formula, eta).

TiePredictions(network, tail, head, p, ...)

Predicted tie probabilities of a model, one per dyad, as R's predict(fit): tail, head (vertex numbers from 0, as igraph's) and p.

table(*fits[, names, digits, stars, ...])

A table of fitted models side by side, as R's texreg.

ResultsTable(fits[, names, digits, stars, ...])

Coefficients, standard errors and fit statistics of several models, as R's texreg tables.

NumericTable(title, index, columns[, ...])

A small table of numbers by name, printed like R's matrices; convert it with to_frame() (needs pandas).

Checking and comparing models#

gof(x[, formula, coef, constraints, nsim, ...])

Goodness of fit of an ERGM, like R's gof().

GofResult(tables, nsim)

Goodness-of-fit tables, by statistic.

GofTable(name, labels, observed, simulated)

One statistic's observed values and simulated distribution.

gofN(fit[, GOF, subset, nsim, seed, ...])

Goodness of fit network by network, for a model of several networks (ergmx.Networks(), ergmx.NetSeries()), as ergm.multi's gofN().

GofNResult(names, table, networks, ...)

Goodness of fit by network (gofN()): a GofNTable per statistic, by name.

GofNTable(name, networks, labels, values)

One statistic of gofN(), by network: observed, fitted, var, var_obs and pearson arrays (NaN where the statistic doesn't vary).

GofNSummary(gof, groups)

Summaries of the observed and fitted values and the Pearson residuals of each statistic over the networks (by group, with by), as ergm.multi's summary(gofN): minimum, quartiles, mean, maximum and the number of networks where the statistic doesn't vary; and the variance and standard deviation of the residuals, which are near 1 for a model that fits.

McmcDiagnostics(names, sample, observed[, ...])

Diagnostics of the MCMC sample of the last Monte Carlo MLE iteration.

compare(*fits)

Compare fitted models of the same network, like R's AIC() and anova().

ModelComparison(fits)

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.

edges()

Number of edges.

mutual([same, by, diff, keep, levels])

Number of reciprocated pairs of ties (directed networks).

asymmetric([attr, diff, keep, levels])

Number of pairs with a tie in one direction only (directed networks); with attr, only pairs of vertices with the same value (by value, with diff=TRUE).

edgecov(x)

Sum over ties of a dyadic covariate.

sender([base, nodes])

Each vertex's out-degree, one statistic per vertex of nodes (by default all but the first; directed networks).

receiver([base, nodes])

Each vertex's in-degree, one statistic per vertex of nodes (by default all but the first; directed networks).

sociality([attr, base, levels, nodes])

Each vertex's degree, one statistic per vertex of nodes (by default all but the first; undirected networks); with attr, only the ties to vertices with the same value (of levels).

kstar(k[, attr, levels])

Number of k-stars, for one or more k (undirected networks); with attr, only those whose vertices all have the same value.

istar(k[, attr, levels])

Number of in-k-stars: sets of k ties to the same vertex (directed networks); with attr, only those whose vertices all have the same value.

ostar(k[, attr, levels])

Number of out-k-stars: sets of k ties from the same vertex (directed networks); with attr, only those whose vertices all have the same value.

degree(d[, by, homophily, levels])

Number of vertices with degree exactly d, for one or more d (undirected networks).

idegree(d[, by, homophily, levels])

Number of vertices with in-degree exactly d, for one or more d (directed networks); by, homophily and levels as in degree().

odegree(d[, by, homophily, levels])

Number of vertices with out-degree exactly d, for one or more d (directed networks); by, homophily and levels as in degree().

isolates()

Number of vertices without ties (in either direction, if directed).

concurrent([by, levels])

Number of vertices with degree 2 or more (undirected networks), by value of by if given.

twopath()

Number of 2-paths: i -> j -> k with i != k if directed, kstar(2) if undirected.

gwdegree([decay, fixed, attr, cutoff, levels])

Geometrically weighted degree distribution (undirected networks).

gwidegree([decay, fixed, attr, cutoff, levels])

Geometrically weighted in-degree distribution (directed networks), by value of attr if given (with a fixed decay).

gwodegree([decay, fixed, attr, cutoff, levels])

Geometrically weighted out-degree distribution (directed networks), by value of attr if given (with a fixed decay).

triangle([attr, diff, levels])

Number of triangles; in directed networks, transitive plus cyclic triples.

ttriple([attr, diff, levels])

Number of transitive triples i -> j -> k with i -> k (directed networks); attr and diff as in triangle().

ctriple([attr, diff, levels])

Number of cyclic triples i -> j -> k -> i (directed networks); attr and diff as in triangle().

transitive()

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.

cycle(k[, semi])

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).

gwesp([decay, fixed, cutoff, type])

Geometrically weighted edgewise shared partners.

gwdsp([decay, fixed, cutoff, type])

Geometrically weighted dyadwise shared partners: as gwesp, over all pairs of vertices, tied or not (ordered pairs if directed).

gwnsp([decay, fixed, cutoff, type])

Geometrically weighted non-edgewise shared partners: as gwesp, over the pairs of vertices without a tie; gwdsp minus gwesp.

esp(d[, type])

Number of ties with exactly d edgewise shared partners, for one or more d.

dsp(d[, type])

Number of pairs of vertices with exactly d shared partners, for one or more d (ordered pairs if directed).

nsp(d[, type])

Number of pairs of vertices without a tie with exactly d shared partners, for one or more d.

nodematch(attr[, diff, keep, levels])

Number of ties between vertices with the same value of attr; with diff=True, one statistic per value.

nodemix(attr[, levels, levels2])

Number of ties for each mixing type: each pair of levels of attr (from sender to receiver, if directed).

nodefactor(attr[, base, levels])

Number of tie endpoints at each level of attr of levels (by default, all but the first; levels=TRUE for all).

nodeifactor(attr[, base, levels])

Number of ties received by vertices at each level of attr of levels (by default, all but the first).

nodeofactor(attr[, base, levels])

Number of ties sent by vertices at each level of attr of levels (by default, all but the first).

nodecov(attr)

Sum over ties of the endpoints' values of the numeric attr.

nodeicov(attr)

Sum over ties of the receiver's value of the numeric attr (directed networks).

nodeocov(attr)

Sum over ties of the sender's value of the numeric attr (directed networks).

absdiff(attr)

Sum over ties of the absolute difference in the numeric attr.

absdiffcat(attr)

For each distinct nonzero absolute difference of the numeric attr, the number of ties with that difference.

density()

The density: the number of edges over the number of dyads.

meandeg()

The mean degree: twice the number of edges over the number of vertices (the number of edges, if directed).

dyadcov(x)

A dyadic covariate by dyad state, in directed networks: its sum over mutual dyads (mutual), over dyads with only the tie from the lower- to the higher-numbered vertex (utri, in the adjacency matrix's upper triangle), and the reverse (ltri); of x, its upper triangle, as ergm.

hamming([x, cov])

The Hamming distance to a reference network x: the number of dyads whose tie differs.

attrcov(attr, mat)

Sum over ties of a covariate of the mixing type of their vertices: the entry of mat (levels x levels of attr, sorted) of the pair of levels.

mm(attrs[, levels, levels2])

The cells of a mixing matrix, as ergm's mm(): "A" (or "~A") for attribute A with itself, "A~B" for rows of A and columns of B (from senders to receivers, if directed), and "A~." or ".~B" for its margins.

diff(attr[, pow, dir, sign_action])

Sum over ties of a function of the difference of the vertices' values of attr: tail minus head (dir="t-h", also "b1-b2") or head minus tail ("h-t", "b2-b1"), transformed by sign_action (R's sign.action: "identity", "abs", "posonly", "negonly") and raised to pow (the sign, for pow=0).

smalldiff(attr, cutoff)

Number of ties whose vertices' values of attr differ by less than cutoff.

nodecovrange(attr)

Sum over vertices of the range of attr over their neighbours (in directed networks, over the out-neighbours plus over the in-neighbours; Hoffman, Block and Snijders 2023).

nodeicovrange(attr)

Sum over vertices of the range of attr over their in-neighbours (directed networks).

nodeocovrange(attr)

Sum over vertices of the range of attr over their out-neighbours (directed networks).

nodefactordistinct(attr[, levels])

Sum over vertices of the number of distinct values of attr among their neighbours (in either direction, if directed).

nodeofactordistinct(attr[, levels])

Sum over vertices of the number of distinct values of attr among their out-neighbours.

nodeifactordistinct(attr[, levels])

Sum over vertices of the number of distinct values of attr among their in-neighbours.

degrange(frm[, to, by, homophily, levels])

Number of vertices with degree in [from, to), for each pair (undirected networks); to defaults to infinity, and either can be recycled.

idegrange(frm[, to, by, homophily, levels])

Number of vertices with in-degree in [from, to) (directed networks), as degrange().

odegrange(frm[, to, by, homophily, levels])

Number of vertices with out-degree in [from, to) (directed networks), as degrange().

degree1_5()

Sum over vertices of their degree to the power 3/2 (undirected networks).

idegree1_5()

Sum over vertices of their in-degree to the power 3/2 (directed networks; idegree1.5).

odegree1_5()

Sum over vertices of their out-degree to the power 3/2 (directed networks; odegree1.5).

concurrentties([by, levels])

Sum over vertices of their ties beyond the first (undirected networks), by value of by if given.

isolatededges()

Number of ties whose two vertices have no other tie (undirected networks).

altkstar(lambda_[, fixed])

Alternating k-stars (Snijders et al. 2006) with weight lambda (undirected networks): sum over vertices of lambda^2 ((1 - 1/lambda)^d - 1 + d / lambda).

triadcensus([levels])

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).

balance()

Number of balanced triads: types 102 and 300 (undirected networks: triads with 1 or 3 ties).

intransitive()

Number of intransitive triads (directed networks): types 111D, 201, 111U, 021C and 030C of the triad census.

simmelian()

Number of Simmelian triads (directed networks): complete triads, type 300.

nearsimmelian()

Number of near-Simmelian triads (directed networks): one tie short of complete, type 210.

simmelianties()

Number of ties in at least one Simmelian triad (directed networks).

transitiveties([attr, levels])

Number of ties i -> j with a two-path i -> k -> j (in undirected networks, ties with a shared partner); with attr, only ties and two-paths whose three vertices have the same value.

cyclicalties([attr, levels])

Number of ties i -> j with a two-path j -> k -> i (in undirected networks, ties with a shared partner); attr as in transitiveties().

threetrail([keep, levels])

Number of 3-trails: walks of three distinct ties (a triangle counts as three).

opentriad()

Number of 2-stars minus three times the number of triangles (undirected networks).

localtriangle(x)

Number of triangles whose three pairs of vertices are neighbours in x (a graph attribute holding a symmetric adjacency matrix, the matrix or a graph).

m2star()

Number of mixed 2-stars i -> j -> k, i != k (directed networks): twopath.

desp(d[, type])

esp() for directed networks only, as ergm's desp.

ddsp(d[, type])

dsp() for directed networks only, as ergm's ddsp.

dnsp(d[, type])

nsp() for directed networks only, as ergm's dnsp.

dgwesp([decay, fixed, cutoff, type])

gwesp() for directed networks only, as ergm's dgwesp.

dgwdsp([decay, fixed, cutoff, type])

gwdsp() for directed networks only, as ergm's dgwdsp.

dgwnsp([decay, fixed, cutoff, type])

gwnsp() for directed networks only, as ergm's dgwnsp.

Bipartite terms#

For bipartite networks (bipartite= in ergm()): b1 terms are about the first mode, b2 terms the second.

b1star(k[, attr, levels])

Number of k-stars centred on first-mode vertices, for one or more k; with attr, only those whose vertices all have the same value.

b2star(k[, attr, levels])

Number of k-stars centred on second-mode vertices, for one or more k; with attr, only those whose vertices all have the same value.

b1degree(d[, by, levels])

Number of first-mode vertices with degree exactly d, for one or more d, by value of by if given.

b2degree(d[, by, levels])

Number of second-mode vertices with degree exactly d, for one or more d, by value of by if given.

gwb1degree([decay, fixed, attr, cutoff, levels])

Geometrically weighted degree distribution of the first mode, by value of attr if given (with a fixed decay).

gwb2degree([decay, fixed, attr, cutoff, levels])

Geometrically weighted degree distribution of the second mode, by value of attr if given (with a fixed decay).

b1concurrent([by, levels])

Number of first-mode vertices with degree 2 or more, by value of by if given.

b2concurrent([by, levels])

Number of second-mode vertices with degree 2 or more, by value of by if given.

b1factor(attr[, base, levels])

For each level of attr among first-mode vertices of levels (by default, all but the first), their ties.

b2factor(attr[, base, levels])

For each level of attr among second-mode vertices of levels (by default, all but the first), their ties.

b1cov(attr)

Sum over ties of the first-mode endpoint's value of the numeric attr.

b2cov(attr)

Sum over ties of the second-mode endpoint's value of the numeric attr.

b1nodematch(attr[, diff, keep, alpha, beta, ...])

Number of 2-stars centred on second-mode vertices whose two first-mode ends have the same value of attr (Bomiriya et al. 2023), by value with diff=TRUE and by value of the centres' byb2attr.

b2nodematch(attr[, diff, keep, alpha, beta, ...])

Number of 2-stars centred on first-mode vertices whose two second-mode ends have the same value of attr; the options as in b1nodematch().

b1dsp(d)

Number of pairs of first-mode vertices with exactly d shared partners, for one or more d.

b2dsp(d)

Number of pairs of second-mode vertices with exactly d shared partners, for one or more d.

gwb1dsp([decay, fixed, cutoff])

Geometrically weighted shared partner distribution of pairs of first-mode vertices.

gwb2dsp([decay, fixed, cutoff])

Geometrically weighted shared partner distribution of pairs of second-mode vertices.

b1degrange(frm[, to, by, homophily, levels])

Number of first-mode vertices with degree in [from, to), as degrange().

b2degrange(frm[, to, by, homophily, levels])

Number of second-mode vertices with degree in [from, to), as degrange().

b1mindegree(d)

Number of first-mode vertices with degree at least d, for one or more d.

b2mindegree(d)

Number of second-mode vertices with degree at least d, for one or more d.

b1sociality([nodes])

Each first-mode vertex's degree, one statistic per vertex of nodes (indices among the first mode's vertices; by default all but the first).

b2sociality([nodes])

Each second-mode vertex's degree, one statistic per vertex of nodes (indices among the second mode's vertices; by default all but the first).

b1starmix(k, attr[, base, diff])

Number of k-stars centred on first-mode vertices whose second-mode ends all have the same value of attr, by value of the centre and (with diff=TRUE) of the ends.

b2starmix(k, attr[, base, diff])

Number of k-stars centred on second-mode vertices whose first-mode ends all have the same value of attr, as b1starmix().

b1twostar(b1attr[, b2attr, base, b1levels, ...])

Number of two-stars centred on first-mode vertices, by the value of b1attr of the centre and the (unordered) values of b2attr of the two ends.

b2twostar(b1attr[, b2attr, base, b1levels, ...])

Number of two-stars centred on second-mode vertices, by the value of b2attr of the centre and the (unordered) values of b1attr of the two ends (b2attr defaults to b1attr).

b1covrange(attr)

Sum over first-mode vertices of the range of attr over their neighbours.

b2covrange(attr)

Sum over second-mode vertices of the range of attr over their neighbours.

b1factordistinct(attr[, levels])

Sum over first-mode vertices of the number of distinct values of attr among their neighbours.

b2factordistinct(attr[, levels])

Sum over second-mode vertices of the number of distinct values of attr among their neighbours.

Operators#

offset(term)

Fix a term's coefficients, as ergm's offset().

F(formula, filter[, negate])

Evaluate formula on the network of the ties that pass filter, as ergm's F().

S(formula, attrs)

Evaluate formula on a subgraph, as ergm's S().

N(formula[, lm, subset, weights, contrasts, ...])

Evaluate formula on each network of ergmx.Networks(), as ergm.multi's N(): with the default lm, the statistics are sums over the networks.

Form(formula[, lm, subset, weights, ...])

tergm's formation model: formula evaluated on the union of the previous and the current network, which only changes when ties form.

Persist(formula[, lm, subset, weights, ...])

tergm's persistence model: formula evaluated on the intersection of the previous and the current network, the ties that persisted, which only changes when ties dissolve.

Diss(formula[, lm, subset, weights, ...])

tergm's dissolution model: Persist() with its statistics negated, so that a positive coefficient means more dissolution.

Cross(formula[, lm, subset, weights, ...])

tergm's cross-sectional model: formula evaluated on the current network of each transition.

Change(formula[, lm, subset, weights, ...])

tergm's change model: formula evaluated on the network of the dyads that changed between the previous and the current network.

terms.Curved(term[, cutoff])

A geometrically weighted term whose decay is estimated, as ergm's fixed=FALSE: a curved exponential family term.

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…).

edge_ages()

Sum over ties of their ages (tergm's edge.ages).

mean_age([emptyval, log])

Mean age of the ties, or of their logarithms with log; emptyval if there is none (tergm's mean.age).

edges_ageinterval(frm[, to])

Number of ties with age in [from, to) (tergm's edges.ageinterval).

edgecov_ages(x)

Sum over ties of a dyadic covariate times their age (tergm's edgecov.ages).

nodefactor_mean_age(attr[, levels, ...])

For each level of attr (all by default), the mean age of the ties' ends at its vertices (tergm's nodefactor.mean.age).

Multilevel terms#

MPNet’s configurations of two-level networks; see the user guide.

star2ax(attr[, levels])

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(attr[, levels])

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(attr[, decay, levels, fixed, cutoff])

AXS1A: alternating X-stars with one A-tie, the sum over A vertices of their A-degree times g(X-degree).

axs1b(attr[, decay, levels, fixed, cutoff])

AXS1B: alternating X-stars with one B-tie, the sum over B vertices of their B-degree times g(X-degree).

aas1x(attr[, decay, levels, fixed, cutoff])

AAS1X: alternating A-stars with one X-tie, the sum over A vertices of g(A-degree) times their X-degree.

abs1x(attr[, decay, levels, fixed, cutoff])

ABS1X: alternating B-stars with one X-tie, the sum over B vertices of g(B-degree) times their X-degree.

aaaxs(attr[, decay, levels, fixed, cutoff])

AAAXS: alternating A-stars and alternating X-stars, the sum over A vertices of g(A-degree) g(X-degree).

abaxs(attr[, decay, levels, fixed, cutoff])

ABAXS: alternating B-stars and alternating X-stars, the sum over B vertices of g(B-degree) g(X-degree).

txax(attr[, levels])

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(attr[, levels])

TXBX: triangles of a B-tie and two X-ties to a common A vertex.

atxax(attr[, decay, levels, fixed, cutoff])

ATXAX: alternating TXAX triangles, the sum over A-ties of g(shared B partners), as gwesp with partners in B.

atxbx(attr[, decay, levels, fixed, cutoff])

ATXBX: alternating TXBX triangles, the sum over B-ties of g(shared A partners).

l3xax(attr[, levels])

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(attr[, levels])

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(attr[, levels])

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(attr[, levels])

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(attr[, 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(attr[, levels])

EXTB: a B-triangle with an X-tie at one of its vertices.

asaxasb(attr[, decay, levels, fixed, cutoff])

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(attr[, levels])

In2StarAX: sum over A vertices of in(v) x(v): an incoming A-tie with an X-tie.

in2starbx(attr[, levels])

In2StarBX: sum over B vertices of in(v) x(v).

out2starax(attr[, levels])

Out2StarAX: sum over A vertices of out(v) x(v): an outgoing A-tie with an X-tie.

out2starbx(attr[, levels])

Out2StarBX: sum over B vertices of out(v) x(v).

axs1ain(attr[, decay, levels, fixed, cutoff])

AXS1Ain: alternating X-stars with one incoming A-tie, the sum over A vertices of in(v) g(x(v)).

axs1bin(attr[, decay, levels, fixed, cutoff])

AXS1Bin: the sum over B vertices of in(v) g(x(v)).

axs1aout(attr[, decay, levels, fixed, cutoff])

AXS1Aout: alternating X-stars with one outgoing A-tie, the sum over A vertices of out(v) g(x(v)).

axs1bout(attr[, decay, levels, fixed, cutoff])

AXS1Bout: the sum over B vertices of out(v) g(x(v)).

aains1x(attr[, decay, levels, fixed, cutoff])

AAinS1X: alternating A-in-stars with one X-tie, the sum over A vertices of g(in(v)) x(v).

abins1x(attr[, decay, levels, fixed, cutoff])

ABinS1X: the sum over B vertices of g(in(v)) x(v).

aaouts1x(attr[, decay, levels, fixed, cutoff])

AAoutS1X: alternating A-out-stars with one X-tie, the sum over A vertices of g(out(v)) x(v).

abouts1x(attr[, decay, levels, fixed, cutoff])

ABoutS1X: the sum over B vertices of g(out(v)) x(v).

txaxarc(attr[, levels])

TXAXarc: over A-arcs, the number of B vertices X-tied to both ends.

txbxarc(attr[, levels])

TXBXarc: over B-arcs, the number of A vertices X-tied to both ends.

txaxreciprocity(attr[, levels])

TXAXreciprocity: over reciprocated pairs of A-arcs, the number of B vertices X-tied to both.

txbxreciprocity(attr[, levels])

TXBXreciprocity: over reciprocated pairs of B-arcs, the number of A vertices X-tied to both.

atxaxarc(attr[, decay, levels, fixed, cutoff])

ATXAXarc: over A-arcs, g(the B vertices X-tied to both ends).

atxbxarc(attr[, decay, levels, fixed, cutoff])

ATXBXarc: over B-arcs, g(the A vertices X-tied to both ends).

atxaxreciprocity(attr[, decay, levels, ...])

ATXAXreciprocity: over reciprocated pairs of A-arcs, g(the B vertices X-tied to both).

atxbxreciprocity(attr[, decay, levels, ...])

ATXBXreciprocity: over reciprocated pairs of B-arcs, g(the A vertices X-tied to both).

l3xaxreciprocity(attr[, levels])

L3XAXreciprocity: over reciprocated pairs of A-arcs, the product of the ends' X-degrees.

l3xbxreciprocity(attr[, levels])

L3XBXreciprocity: over reciprocated pairs of B-arcs, the product of the ends' X-degrees.

l3axbin(attr[, levels])

L3AXBin: over X-ties a -> b, in(a) in(b): both ends receive within their level.

l3axbout(attr[, levels])

L3AXBout: over X-ties a -> b, out(a) out(b): both ends send within their level.

l3axbpath(attr[, levels])

L3AXBpath: over X-ties a -> b, in(a) out(b): a path from A through X into B.

l3bxapath(attr[, levels])

L3BXApath: over X-ties a -> b, out(a) in(b): a path from B through X into A.

c4axbentrainment(attr[, levels])

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(attr[, levels])

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(attr[, levels])

C4AXBexchangeAreciprocity: 4-cycles of a reciprocated pair of A-arcs, a B-arc and two X-ties.

c4axbexchangebreciprocity(attr[, levels])

C4AXBexchangeBreciprocity: 4-cycles of an A-arc, a reciprocated pair of B-arcs and two X-ties.

c4axbreciprocity(attr[, levels])

C4AXBreciprocity: 4-cycles of reciprocated pairs of A- and B-arcs and two X-ties.

ainasxainbs(attr[, decay, levels, fixed, cutoff])

AinASXAinBS: over X-ties a -> b, g(in(a)) g(in(b)): alternating in-stars at both ends.

aoutasxaoutbs(attr[, decay, levels, fixed, ...])

AoutASXAoutBS: over X-ties a -> b, g(out(a)) g(out(b)).

ainasxaoutbs(attr[, decay, levels, fixed, ...])

AinASXAoutBS: over X-ties a -> b, g(in(a)) g(out(b)).

aoutasxainbs(attr[, decay, levels, fixed, ...])

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.parse_constraints(constraints)

Constraints from a string in R syntax ("~bd(maxout=4) + blocks('level')"), a constraint, a list of them, or None.

constraints.Bd([attribs, maxout, maxin, ...])

Bounds on degrees, as ergm's bd(): at most maxout out-ties per vertex, and so on.

constraints.Blocks(attr[, levels, levels2])

Fix the dyads of some mixing types of a vertex attribute, as ergm's blocks(): those whose toggle would change nodemix(attr, levels, levels2).

constraints.Degrees()

Preserve every vertex's degree (in- and out-degrees, if directed).

constraints.ODegrees()

Preserve every vertex's out-degree (directed networks).

constraints.IDegrees()

Preserve every vertex's in-degree (directed networks).

constraints.Edges()

Preserve the number of edges, as ergm's edges constraint.

constraints.B1Degrees()

Preserve the degrees of the first mode's vertices (bipartite networks).

constraints.B2Degrees()

Preserve the degrees of the second mode's vertices (bipartite networks).

constraints.Fixedas([fixed_dyads, present, ...])

Fix some dyads at their observed value, as ergm's fixedas(): fixed_dyads (R's fixed.dyads) as they are, present as ties and absent as non-ties (checked).

constraints.Fixallbut(free_dyads)

Fix every dyad but free_dyads (R's free.dyads), as ergm's fixallbut().

constraints.Observed()

Fix the observed dyads: only those whose value is missing vary, as ergm's observed constraint (to simulate the missing ties).

constraints.Blockdiag(attr[, noncontig])

Allow ties only between vertices with the same value of attr, as ergm's blockdiag(): the dyads between blocks are fixed at no tie.

constraints.DyadsConstraint([fix, vary])

Fix or free the dyads that dyad-independent terms count, as ergm's Dyads(): with fix, the dyads where any of its terms' statistics change are fixed; with vary, only those where any of its terms' statistics change may vary; with both, the dyads that either lets vary.

Formulas#

parse_formula(formula)

Parse a formula string into terms.

Formula(terms)

A sum of model terms.

Term()

A model term: one or more network statistics.

Errors#

DegeneracyError

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.

FormulaError

The formula can't be parsed.

ErgmDifferenceWarning

A term whose statistic differs from what R's ergm computes for it, because ergmx follows ergm's documented definition.

Datasets#

datasets.load(name[, backend])

Load a bundled network.

datasets.names()

Names of the bundled networks.

datasets.describe(name)

What a bundled network is, its source and its vertex attributes.