ergmx.ergm#

ergmx.ergm(network, formula, *, constraints=None, offset_coef=None, bipartite=None, estimate='MLE', init=None, seed=None, eval_loglik=True, control=None, **control_args)[source]#

Fit an exponential-family random graph model.

Parameters:
  • network (igraph.Graph, networkx.Graph, Networks or NetSeries) – The observed network. Vertex attributes are available to the terms. Edges with a true na attribute mark dyads whose value is unknown: the fit is then conditional on the observed dyads (missing at random, as in ergm). Several networks combined with ergmx.Networks() are modeled jointly (with N() terms), and the transitions of a ergmx.NetSeries() conditionally on the network before each (with tergm’s operators; see ergmx.tergm()).

  • formula (str or terms) – The model, in R syntax: "edges + nodematch('Grade') + gwesp(0.5, fixed=TRUE)", or terms combined with +.

  • constraints (str, optional) – Sample space constraints, in R syntax: "bd(maxout=5)", "degrees", "blocks('level', levels2=TRUE)"… See ergmx.constraints.

  • offset_coef (array-like, optional) – The fixed coefficients of the offset() terms, in formula order; -inf forbids the ties they count.

  • bipartite (str or bool, optional) – For a bipartite (two-mode) network, the vertex attribute giving each vertex’s mode: false or 0 for the first mode (ergm’s “b1”), true or 1 for the second. True uses igraph’s type or networkx’s bipartite attribute. Only ties between the modes are modeled.

  • estimate ({"MLE", "MPLE", "CD"}) – "MLE" (default) gives the exact MLE of dyad-independent models and the Monte Carlo MLE of the others. "MPLE" stops at the maximum pseudo-likelihood estimate, and "CD" at the contrastive divergence estimate (as in ergm; no standard errors).

  • init ({"MPLE", "CD"} or array-like, optional) – Starting coefficients for the Monte Carlo MLE: the MPLE (the default, unless the constraints are dyad-dependent), the contrastive divergence estimate (started from the MPLE; the default with dyad-dependent constraints, as in ergm), or given values.

  • seed (int, optional) – Seed for reproducible results.

  • eval_loglik (bool) – Estimate the log-likelihood of dyad-dependent models, for AIC and BIC, by path sampling (as ergm does by default). Dyad-independent models always get their exact log-likelihood.

  • control (Control, optional) – MCMC and estimation settings. Keyword arguments (samplesize=..., interval=..., n_chains=...) override single settings.

Returns:

ErgmFit