Learn R Programming

ergm (version 4.12.0)

Fit, Simulate and Diagnose Exponential-Family Models for Networks

Description

An integrated set of tools to analyze and simulate networks based on exponential-family random graph models (ERGMs). 'ergm' is a part of the Statnet suite of packages for network analysis. See Hunter, Handcock, Butts, Goodreau, and Morris (2008) and Krivitsky, Hunter, Morris, and Klumb (2023) .

Copy Link

Version

Install

install.packages('ergm')

Monthly Downloads

8,222

Version

4.12.0

License

GPL-3 + file LICENSE

Maintainer

Pavel N. Krivitsky

Last Published

February 17th, 2026

Functions in ergm (4.12.0)

Curve-ergmTerm

Impose a curved structure on term parameters
DiscUnif-ergmProposal

TODO
CondOutDegree-ergmProposal

MHp for odegree constraints
CondInDegreeDist-ergmProposal

MHp for idegreedist constraints
DiscUnif-ergmReference

Discrete Uniform reference
DiscUnif2-ergmProposal

TODO
For-ergmTerm

A for operator for terms
F-ergmTerm

Filtering on arbitrary one-term model
DistRLE-ergmProposal

TODO
Exp-ergmTerm

Exponentiate a network's statistic
Dyads-ergmConstraint

Constrain fixed or varying dyad-independent terms
DiscUnifNonObserved-ergmProposal

TODO
I-ergmConstraint

Substitute a formula into the constraints formula
S-ergmTerm

Evaluation on an induced subgraph
I-ergmTerm

Substitute a formula into the model formula
StdNormal-ergmReference

Standard Normal reference
Label-ergmTerm

Modify terms' coefficient names
Log-ergmTerm

Take a natural logarithm of a network's statistic
SPDyad-ergmProposal

A proposal alternating between TNT and a triad-focused proposal
StdNormal-ergmProposal

TODO
Project-ergmTerm

Evaluation on a projection of a bipartite network
Prod-ergmTerm

A product (or an arbitrary power combination) of one or more formulas
TNT-ergmProposal

Default MH algorithm
Symmetrize-ergmTerm

Evaluation on symmetrized (undirected) network
Sum-ergmTerm

A sum (or an arbitrary linear combination) of one or more formulas
Unif-ergmProposal

TODO
approx.hotelling.diff.test

Approximate Hotelling T^2-Test for One or Two Population Means
as.network.numeric

Create a Simple Random network of a Given Size
Offset-ergmTerm

Terms with fixed coefficients
NodematchFilter-ergmTerm

Filtering on nodematch
absdiff-ergmTerm

Absolute difference in nodal attribute
atleast-ergmTerm

Number of dyads with values greater than or equal to a threshold
altkstar-ergmTerm

Alternating \(k\)-star
anova.ergm

ANOVA for ERGM Fits
atmost-ergmTerm

Number of dyads with values less than or equal to a threshold
asymmetric-ergmTerm

Asymmetric dyads
as.rlebdm.ergm_conlist

Extract dyad-level ERGM constraint information into an rlebdm object
Unif-ergmReference

Continuous Uniform reference
absdiffcat-ergmTerm

Categorical absolute difference in nodal attribute
b1cov-ergmTerm

Main effect of a covariate for the first mode in a bipartite network
b1concurrent-ergmTerm

Concurrent node count for the first mode in a bipartite network
b1covrange-ergmTerm

Range of covariate values for neighbors of a mode-1 node
UnifNonObserved-ergmProposal

TODO
HammingConstantEdges-ergmProposal

TODO
ConstantEdges-ergmProposal

MHp for edges constraints
HammingTNT-ergmProposal

TODO
CondOutDegreeDist-ergmProposal

MHp for odegreedist constraints
attrcov-ergmTerm

Edge covariate by attribute pairing
b1mindegree-ergmTerm

Minimum degree for the first mode in a bipartite network
b1degree-ergmTerm

Degree for the first mode in a bipartite network
b1degrange-ergmTerm

Degree range for the first mode in a bipartite network
b1sociality-ergmTerm

Degree
b1degrees-ergmConstraint

Preserve the actor degree for bipartite networks
b1star-ergmTerm

\(k\)-stars for the first mode in a bipartite network
b1starmix-ergmTerm

Mixing matrix for \(k\)-stars centered on the first mode of a bipartite network
b2concurrent-ergmTerm

Concurrent node count for the second mode in a bipartite network
b1dsp-ergmTerm

Dyadwise shared partners for dyads in the first bipartition
b2cov-ergmTerm

Main effect of a covariate for the second mode in a bipartite network
b2degrees-ergmConstraint

Preserve the receiver degree for bipartite networks
b2degree-ergmTerm

Degree for the second mode in a bipartite network
b2covrange-ergmTerm

Range of covariate values for neighbors of a mode-2 node
b1nodematch-ergmTerm

Nodal attribute-based homophily effect for the first mode in a bipartite network
b2degrange-ergmTerm

Degree range for the second mode in a bipartite network
b2star-ergmTerm

\(k\)-stars for the second mode in a bipartite network
b1twostar-ergmTerm

Two-star census for central nodes centered on the first mode of a bipartite network
b2dsp-ergmTerm

Dyadwise shared partners for dyads in the second bipartition
b1factordistinct-ergmTerm

Number of distinct neighbor types for the first node
b2nodematch-ergmTerm

Nodal attribute-based homophily effect for the second mode in a bipartite network
b1factor-ergmTerm

Factor attribute effect for the first mode in a bipartite network
b2factor-ergmTerm

Factor attribute effect for the second mode in a bipartite network
b2starmix-ergmTerm

Mixing matrix for \(k\)-stars centered on the second mode of a bipartite network
b2sociality-ergmTerm

Degree
b2factordistinct-ergmTerm

Number of distinct neighbor types for the second mode
balance-ergmTerm

Balanced triads
b2twostar-ergmTerm

Two-star census for central nodes centered on the second mode of a bipartite network
bd-ergmConstraint

Constrain maximum and minimum vertex degree
b2mindegree-ergmTerm

Minimum degree for the second mode in a bipartite network
blockdiag-ergmConstraint

Block-diagonal structure constraint
cdf-ergmTerm

Empirical cumulative distribution function (unnormalized) of the network's dyad values
control.ergm

Auxiliary function for fine-tuning ERGM fitting.
coincidence-ergmTerm

Coincident node count for the second mode in a bipartite (aka two-mode) network
check.ErgmTerm

Ensures an Ergm Term and its Arguments Meet Appropriate Conditions
blocks-ergmConstraint

Constrain blocks of dyads defined by mixing type on a vertex attribute.
call.ErgmTerm

Locate and call an ERGM term initialization function.
cohab

Target statistics and model fit to a hypothetical 50,000-node network population with 50,000 nodes based on egocent
control.san

Auxiliary for Controlling SAN
control.gof

Auxiliary for Controlling ERGM Goodness-of-Fit Evaluation
control.ergm.bridge

Auxiliaries for Controlling ergm.bridge.llr() and logLik.ergm()
concurrent-ergmTerm

Concurrent node count
concurrentties-ergmTerm

Concurrent tie count
degcor-ergmTerm

Degree Correlation
ctriple-ergmTerm

Cyclic triples
degrange-ergmTerm

Degree range
cyclicalweights-ergmTerm

Cyclical weights
degcrossprod-ergmTerm

Degree Cross-Product
cycle-ergmTerm

k-Cycle Census
degree-ergmTerm

Degree
degree1.5-ergmTerm

Degree to the 3/2 power
control.simulate.ergm

Auxiliary for Controlling ERGM Simulation
cyclicalties-ergmTerm

Cyclical ties
dyadnoise-ergmConstraint

A soft constraint to adjust the sampled distribution for dyad-level noise with known perturbation probabilities
degreedist

Computes and Returns the Degree Distribution Information for a Given Network
dsp-ergmTerm

Directed dyadwise shared partners
dyadnoiseTNT-ergmProposal

TODO
degrees-ergmConstraint

Preserve the degree of each vertex of the given network
density-ergmTerm

Density
diff-ergmTerm

Difference
degreedist-ergmConstraint

Preserve the degree distribution of the given network
dyadnoise-ergmProposal

TODO
dyadcov-ergmTerm

Dyadic covariate
edgecov-ergmTerm

Edge covariate
equalto-ergmTerm

Number of dyads with values equal to a specific value (within tolerance)
enformulate.curved-deprecated

Convert a curved ERGM into a form suitable as initial values for the same ergm. Deprecated in 4.0.0.
edges-ergmConstraint

Preserve the edge count of the given network
ergm-deprecated

Functions that will no longer be supported in future releases of the package
.dyads-ergmConstraint

A meta-constraint indicating handling of arbitrary dyadic constraints
ergm-defunct

Functions that have been removed from this package
ecoli

Two versions of an E. Coli network dataset
edges-ergmTerm

Number of edges in the network
egocentric-ergmConstraint

Preserve values of dyads incident on vertices with given attribute
ergm.allstats

Calculate all possible vectors of statistics on a network for an ERGM
ergm-options

Global options and term options for the ergm package
ergm-parallel

Parallel Processing in the ergm Package
ergm.design

Obtain the set of informative dyads based on the network structure.
ergm-errors

Sensible error and warning messages by ergm initializers
ergm-package

ergm: Fit, Simulate and Diagnose Exponential-Family Models for Networks
ergm.bridge.llr

Bridge sampling to evaluate ERGM log-likelihoods and log-likelihood ratios
ergm

Exponential-Family Random Graph Models
ergm.estfun

Compute the Sample Estimating Function Values of an ERGM.
ergmKeyword

Keywords defined for Exponential-Family Random Graph Models
ergm.getnetwork

Acquire and verify the network from the LHS of an ergm formula and verify that it is a valid network.
ergm-internal

Internal ergm Objects
ergm.eta

Operations to map curved ergm() parameters onto canonical parameters
ergm.geodistdist

Calculate geodesic distance distribution for a network or edgelist
ergmHint

MCMC Hints for Exponential-Family Random Graph Models
ergmConstraint

Sample Space Constraints for Exponential-Family Random Graph Models
ergmMPLE

ERGM Predictors and response for logistic regression calculation of MPLE
ergm.mple

Find a maximizer to the psuedolikelihood function
ergmAuxiliary

Auxiliaries to Facilitate Terms in Exponential Family Random Graph Models
ergm_MCMC_sample

Internal Function to Sample Networks and Network Statistics
ergm_GWDECAY

Curved settings for geometric weights for the gw* terms
ergmTerm

Terms used in Exponential Family Random Graph Models
ergm_Cstate_clear

ergm.godfather

A function to apply a given series of changes to a network.
ergm_dyadgen_select

A helper function to select and construct a dyad generator for C.
ergm_cutoff_message

Helper function for constructing gw* cutoff error messages
ergm_plot.mcmc.list

Plot MCMC list using lattice package graphics
ergm_preprocess_response

Update the network and the response argument.
ergm_mk_std_op_namewrap

Combine an operator term's and a subterm's name in a standard fashion.
ergm_model

Internal representation of an ergm network model
ergmReference

Reference Measures for Exponential-Family Random Graph Models
ergmProposal

Metropolis-Hastings Proposal Methods for ERGM MCMC
ergm_proposal_table

Table mapping reference,constraints, etc. to ERGM Metropolis-Hastings proposals
ergm_state

A Representation of ERGM state
faux.magnolia.high

Goodreau's Faux Magnolia High School as a network object
ergm_propagate_ext.encode

Extended states for submodels
ergm_bd_init

Initializes the parameters to bound degree during sampling
ergm_edgecov_args

A common pattern for obtaining an edge covariate
faux.mesa.high

Goodreau's Faux Mesa High School as a network object
ergm_SAN_slave

Internal Function to Perform Simulated Annealing
fixedas-ergmConstraint

Fix specific dyads
ergm_proposal

Functions to initialize the ergm_proposal object
fixallbut-ergmConstraint

Preserve the dyad status in all but the given edges
gwb1dsp-ergmTerm

Geometrically weighted dyadwise shared partner distribution for dyads in the first bipartition
gwb2degree-ergmTerm

Geometrically weighted degree distribution for the second mode in a bipartite network
ergm_keyword

Dynamic ERGM keyword registry
fix.curved

Convert a curved ERGM into a corresponding "fixed" ERGM.
faux.desert.high

Faux desert High School as a network object
florentine

Florentine Family Marriage and Business Ties Data as a "network" object
g4

Goodreau's four node network as a "network" object
faux.dixon.high

Faux dixon High School as a network object
gwodegree-ergmTerm

Geometrically weighted out-degree distribution
geweke.diag.mv

Multivariate version of coda's coda::geweke.diag().
hamming-ergmConstraint

Preserve the hamming distance to the given network (BROKEN: Do NOT Use)
gof

Conduct Goodness-of-Fit Diagnostics on a Exponential Family Random Graph Model
ergm_symmetrize

Return a symmetrized version of a binary network
ergm_state_cache

A rudimentary cache for large objects
gwdsp-ergmTerm

Geometrically weighted dyadwise shared partner distribution
greaterthan-ergmTerm

Number of dyads with values strictly greater than a threshold
esp-ergmTerm

Directed edgewise shared partners
gwesp-ergmTerm

Geometrically weighted edgewise shared partner distribution
gwb1degree-ergmTerm

Geometrically weighted degree distribution for the first mode in a bipartite network
gwb2dsp-ergmTerm

Geometrically weighted dyadwise shared partner distribution for dyads in the second bipartition
gwdegree-ergmTerm

Geometrically weighted degree distribution
hamming-ergmTerm

Hamming distance
ergmlhs

An API for specifying aspects of an ergm model in the LHS/basis network.
is.curved

Testing for curved exponential family
get.node.attr

Retrieve and check assumptions about vertex attributes (nodal covariates) in a network
is.dyad.independent

Testing for dyad-independence
isolatededges-ergmTerm

Isolated edges
is.valued

Function to check whether an ERGM fit or some aspect of it is valued
idegrange-ergmTerm

In-degree range
idegree1.5-ergmTerm

In-degree to the 3/2 power
meandeg-ergmTerm

Mean vertex degree
logLik.ergm

A logLik() method for ergm fits.
localtriangle-ergmTerm

Triangles within neighborhoods
gwnsp-ergmTerm

Geometrically weighted non-edgewise shared partner distribution
mcmc.diagnostics

Conduct MCMC diagnostics on a model fit
idegree-ergmTerm

In-degree
gwidegree-ergmTerm

Geometrically weighted in-degree distribution
idegreedist-ergmConstraint

Preserve the indegree distribution
idegrees-ergmConstraint

Preserve indegree for directed networks
kapferer

Kapferer's tailor shop data
nodal_attributes

Specifying nodal attributes and their levels
kstar-ergmTerm

\(k\)-stars
mm-ergmTerm

Mixing matrix cells and margins
nodecov-ergmTerm

Main effect of a covariate
nodecovrange-ergmTerm

Range of covariate values for neighbors of a node
logLikNull

Calculate the null model likelihood
nodecovar-ergmTerm

Covariance of undirected dyad values incident on each actor
m2star-ergmTerm

Mixed 2-stars, a.k.a 2-paths
istar-ergmTerm

In-stars
isolates-ergmTerm

Isolates
mutual-ergmTerm

Mutuality
nearsimmelian-ergmTerm

Near simmelian triads
intransitive-ergmTerm

Intransitive triads
ininterval-ergmTerm

Number of dyads whose values are in an interval
network.list

A convenience container for a list of network objects, output by simulate.ergm() among others.
nodal_attributes-API

Helper functions for specifying nodal attribute levels
molecule

Synthetic network with 20 nodes and 28 edges
nodeicovrange-ergmTerm

Range of covariate values for in-neighbors of a node
nodeocov-ergmTerm

Main effect of a covariate for out-edges
nodemix-ergmTerm

Nodal attribute mixing
nodeicovar-ergmTerm

Covariance of in-dyad values incident on each actor
nodeicov-ergmTerm

Main effect of a covariate for in-edges
nodematch-ergmTerm

Uniform homophily and differential homophily
nodeifactordistinct-ergmTerm

Number of distinct in-neighbor types
nodeofactor-ergmTerm

Factor attribute effect for out-edges
nodeofactordistinct-ergmTerm

Number of distinct out-neighbor types
nodeocovrange-ergmTerm

Range of covariate values for out-neighbors of a node
nodeocovar-ergmTerm

Covariance of out-dyad values incident on each actor
opentriad-ergmTerm

Open triads
odegrees-ergmConstraint

Preserve outdegree for directed networks
nvattr.copy.network

Copy network- and vertex-level attributes between two network objects
observed-ergmConstraint

Preserve the observed dyads of the given network
param_names

Names of the parameters associated with an object.
ostar-ergmTerm

k-Outstars
odegreedist-ergmConstraint

Preserve the outdegree distribution
nodeifactor-ergmTerm

Factor attribute effect for in-edges
odegree1.5-ergmTerm

Out-degree to the 3/2 power
rank_test.ergm

A lack-of-fit test for ERGMs
receiver-ergmTerm

Receiver effect
nparam

Length of the parameter vector associated with an object or with its terms.
nsp-ergmTerm

Directed non-edgewise shared partners
nodefactordistinct-ergmTerm

Number of distinct neighbor types
nodefactor-ergmTerm

Factor attribute effect
predict.formula

ERGM-based tie probabilities
odegrange-ergmTerm

Out-degree range
odegree-ergmTerm

Out-degree
randomtoggle-ergmProposal

Propose a randomly selected dyad to toggle
simmelian-ergmTerm

Simmelian triads
simulate.formula

A simulate Method for formula objects that dispatches based on the Left-Hand Side
san

Generate networks with a given set of network statistics
search.ergmTerms

Search ERGM terms, constraints, references, hints, and proposals
simulate.ergm

Draw from the distribution of an Exponential Family Random Graph Model
simmelianties-ergmTerm

Ties in simmelian triads
shrink_into_CH

Identify the position of a point relative to the convex hull of a set of points
sender-ergmTerm

Sender effect
sociality-ergmTerm

Undirected degree
snctrl

Statnet Control
sum-ergmTerm

Sum of dyad values (optionally taken to a power)
sampson

Longitudinal and cumulative networks of positive and negative affect in a monastery
sparse-ergmHint

Sparse network
.spcache.net-ergmAuxiliary

Shared Partner Cache
rlebdm

RLE-Compressed Boolean Dyad Matrix
triadcensus-ergmTerm

Triad census
triadic-ergmHint

Network with strong clustering (triad-closure) effects
strat-ergmHint

Stratify Proposed Toggles by Mixing Type on a Vertex Attribute
spectrum0.mvar

Multivariate version of coda's spectrum0.ar().
summary.ergm

Summarizing ERGM Model Fits
smallerthan-ergmTerm

Number of dyads with values strictly smaller than a threshold
smalldiff-ergmTerm

Number of ties between actors with similar attribute values
summary.ergm_model

Evaluate network summary statistics from an initialized ergm model
ttriple-ergmTerm

Transitive triples
summary.formula

Calculation of network or graph statistics or other attributes specified on a formula
twopath-ergmTerm

2-Paths
wtd.median

Weighted Median
transitiveweights-ergmTerm

Transitive weights
transitiveties-ergmTerm

Transitive ties
update.network

Update the edges in a network based on a matrix
wrap.ergm_model

Wrap a submodel's curved, empty network statistics, and extended state (read-only) specification (if present) for output from an InitErgmTerm or InitWtErgmTerm.
threetrail-ergmTerm

Three-trails
summary_formula

Dispatching a summary function based on the class of the LHS of a formula.
transitive-ergmTerm

Transitive triads
to_ergm_Cdouble

Methods to serialize objects into numeric vectors for passing to the C side.
tripercent-ergmTerm

Triangle percentage
triangle-ergmTerm

Triangles