Learn R Programming

ergm (version 4.9.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

6,396

Version

4.9.0

License

GPL-3 + file LICENSE

Maintainer

Pavel N. Krivitsky

Last Published

June 10th, 2025

Functions in ergm (4.9.0)

Dyads-ergmConstraint

Constrain fixed or varying dyad-independent terms
CondOutDegreeDist-ergmProposal

MHp for odegreedist constraints
DiscUnif-ergmReference

Discrete Uniform reference
Curve-ergmTerm

Impose a curved structure on term parameters
HammingTNT-ergmProposal

TODO
NodematchFilter-ergmTerm

Filtering on nodematch
Log-ergmTerm

Take a natural logarithm of a network's statistic
Exp-ergmTerm

Exponentiate a network's statistic
F-ergmTerm

Filtering on arbitrary one-term model
StdNormal-ergmProposal

TODO
Label-ergmTerm

Modify terms' coefficient names
Sum-ergmTerm

A sum (or an arbitrary linear combination) of one or more formulas
For-ergmTerm

A for operator for terms
StdNormal-ergmReference

Standard Normal reference
HammingConstantEdges-ergmProposal

TODO
SPDyad-ergmProposal

A proposal alternating between TNT and a triad-focused proposal
Offset-ergmTerm

Terms with fixed coefficients
Symmetrize-ergmTerm

Evaluation on symmetrized (undirected) network
Unif-ergmReference

Continuous Uniform reference
Prod-ergmTerm

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

TODO
Unif-ergmProposal

TODO
TNT-ergmProposal

Default MH algorithm
absdiffcat-ergmTerm

Categorical absolute difference in nodal attribute
altkstar-ergmTerm

Alternating \(k\)-star
atleast-ergmTerm

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

Asymmetric dyads
anova.ergm

ANOVA for ERGM Fits
Project-ergmTerm

Evaluation on a projection of a bipartite network
atmost-ergmTerm

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

Edge covariate by attribute pairing
approx.hotelling.diff.test

Approximate Hotelling T^2-Test for One or Two Population Means
absdiff-ergmTerm

Absolute difference in nodal attribute
b1degrees-ergmConstraint

Preserve the actor degree for bipartite networks
b1twostar-ergmTerm

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

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

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

Evaluation on an induced subgraph
as.rlebdm.ergm_conlist

Extract dyad-level ERGM constraint information into an rlebdm object
as.network.numeric

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

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

Number of distinct neighbor types for the first node
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
b1star-ergmTerm

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

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

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

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

Minimum degree for the second mode in a bipartite network
b1factor-ergmTerm

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

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

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

Balanced triads
b2degrees-ergmConstraint

Preserve the receiver degree for bipartite networks
b2dsp-ergmTerm

Dyadwise shared partners for dyads in the second bipartition
call.ErgmTerm

Locate and call an ERGM term initialization function.
bd-ergmConstraint

Constrain maximum and minimum vertex degree
b2factor-ergmTerm

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

Number of distinct neighbor types for the second mode
cohab

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

Coincident node count for the second mode in a bipartite (aka two-mode) network
b1degrange-ergmTerm

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

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

Range of covariate values for neighbors of a mode-1 node
b2cov-ergmTerm

Main effect of a covariate for the second mode in a bipartite network
check.ErgmTerm

Ensures an Ergm Term and its Arguments Meet Appropriate Conditions
b1nodematch-ergmTerm

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

Degree
b2sociality-ergmTerm

Degree
b2starmix-ergmTerm

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

\(k\)-stars for the second mode in a bipartite network
blockdiag-ergmConstraint

Block-diagonal structure constraint
blocks-ergmConstraint

Constrain blocks of dyads defined by mixing type on a vertex attribute.
cycle-ergmTerm

k-Cycle Census
concurrent-ergmTerm

Concurrent node count
concurrentties-ergmTerm

Concurrent tie count
control.gof

Auxiliary for Controlling ERGM Goodness-of-Fit Evaluation
degreedist

Computes and Returns the Degree Distribution Information for a Given Network
degreedist-ergmConstraint

Preserve the degree distribution of the given network
cyclicalweights-ergmTerm

Cyclical weights
control.san

Auxiliary for Controlling SAN
degcor-ergmTerm

Degree Correlation
degree-ergmTerm

Degree
degree1.5-ergmTerm

Degree to the 3/2 power
cyclicalties-ergmTerm

Cyclical ties
edgecov-ergmTerm

Edge covariate
b2twostar-ergmTerm

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

Dyadic covariate
control.ergm

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

Degree range
degcrossprod-ergmTerm

Degree Cross-Product
ctriple-ergmTerm

Cyclic triples
.dyads-ergmConstraint

A meta-constraint indicating handling of arbitrary dyadic constraints
edges-ergmConstraint

Preserve the edge count of the given network
control.simulate.ergm

Auxiliary for Controlling ERGM Simulation
control.ergm.bridge

Auxiliaries for Controlling ergm.bridge.llr() and logLik.ergm()
dyadnoise-ergmConstraint

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

Density
degrees-ergmConstraint

Preserve the degree of each vertex of the given network
dyadnoiseTNT-ergmProposal

TODO
ecoli

Two versions of an E. Coli network dataset
dyadnoise-ergmProposal

TODO
diff-ergmTerm

Difference
dsp-ergmTerm

Directed dyadwise shared partners
ergm-internal

Internal ergm Objects
ergm-errors

Sensible error and warning messages by ergm initializers
enformulate.curved-deprecated

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

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

ergm: Fit, Simulate and Diagnose Exponential-Family Models for Networks
ergm-defunct

Functions that have been removed from this package
ergm-deprecated

Functions that will no longer be supported in future releases of the package
edges-ergmTerm

Number of edges in the network
egocentric-ergmConstraint

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

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

Parallel Processing in the ergm Package
ergm.eta

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

Calculate all possible vectors of statistics on a network for an ERGM
ergm.estfun

Compute the Sample Estimating Function Values of an ERGM.
ergm

Exponential-Family Random Graph Models
ergm.bridge.llr

Bridge sampling to evaluate ERGM log-likelihoods and log-likelihood ratios
equalto-ergmTerm

Number of dyads with values equal to a specific value (within tolerance)
ergm.getnetwork

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

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

Metropolis-Hastings Proposal Methods for ERGM MCMC
ergm.geodistdist

Calculate geodesic distance distribution for a network or edgelist
ergmHint

MCMC Hints for Exponential-Family Random Graph Models
ergmKeyword

Keywords defined for Exponential-Family Random Graph Models
ergmConstraint

Sample Space Constraints for Exponential-Family Random Graph Models
ergmTerm

Terms used in Exponential Family Random Graph Models
ergmAuxiliary

Auxiliaries to Facilitate Terms in Exponential Family Random Graph Models
ergm_Cstate_clear

ergmReference

Reference Measures for Exponential-Family Random Graph Models
ergm_GWDECAY

Curved settings for geometric weights for the gw* terms
ergm.mple

Find a maximizer to the psuedolikelihood function
ergmMPLE

ERGM Predictors and response for logistic regression calculation of MPLE
ergm_MCMC_sample

Internal Function to Sample Networks and Network Statistics
ergm_keyword

Dynamic ERGM keyword registry
ergm_mk_std_op_namewrap

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

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

Internal representation of an ergm network model
ergm_cutoff_message

Helper function for constructing gw* cutoff error messages
ergm_edgecov_args

A common pattern for obtaining an edge covariate
ergm_bd_init

Initializes the parameters to bound degree during sampling
ergm_SAN_slave

Internal Function to Perform Simulated Annealing
ergm_state_cache

A rudimentary cache for large objects
ergm_symmetrize

Return a symmetrized version of a binary network
ergm_propagate_ext.encode

Extended states for submodels
ergm_proposal

Functions to initialize the ergm_proposal object
ergm_plot.mcmc.list

Plot MCMC list using lattice package graphics
ergm_preprocess_response

Update the network and the response argument.
ergm_proposal_table

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

A Representation of ERGM state
g4

Goodreau's four node network as a "network" object
esp-ergmTerm

Directed edgewise shared partners
get.node.attr

Retrieve and check assumptions about vertex attributes (nodal covariates) in a network
ergmlhs

An API for specifying aspects of an ergm model in the LHS/basis network.
faux.dixon.high

Faux dixon High School as a network object
fixedas-ergmConstraint

Fix specific dyads
florentine

Florentine Family Marriage and Business Ties Data as a "network" object
faux.desert.high

Faux desert High School as a network object
faux.mesa.high

Goodreau's Faux Mesa High School as a network object
faux.magnolia.high

Goodreau's Faux Magnolia High School as a network object
greaterthan-ergmTerm

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

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

Geometrically weighted degree distribution
gwb2dsp-ergmTerm

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

Hamming distance
idegrange-ergmTerm

In-degree range
gwesp-ergmTerm

Geometrically weighted edgewise shared partner distribution
idegree1.5-ergmTerm

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

Geometrically weighted dyadwise shared partner distribution
idegree-ergmTerm

In-degree
idegreedist-ergmConstraint

Preserve the indegree distribution
gwb1dsp-ergmTerm

Geometrically weighted dyadwise shared partner distribution for dyads in the first bipartition
kapferer

Kapferer's tailor shop data
gwb2degree-ergmTerm

Geometrically weighted degree distribution for the second mode in a bipartite network
idegrees-ergmConstraint

Preserve indegree for directed networks
hamming-ergmConstraint

Preserve the hamming distance to the given network (BROKEN: Do NOT Use)
isolates-ergmTerm

Isolates
gwodegree-ergmTerm

Geometrically weighted out-degree distribution
istar-ergmTerm

In-stars
kstar-ergmTerm

\(k\)-stars
fix.curved

Convert a curved ERGM into a corresponding "fixed" ERGM.
fixallbut-ergmConstraint

Preserve the dyad status in all but the given edges
geweke.diag.mv

Multivariate version of coda's coda::geweke.diag().
is.curved

Testing for curved exponential family
gof

Conduct Goodness-of-Fit Diagnostics on a Exponential Family Random Graph Model
is.dyad.independent

Testing for dyad-independence
is.valued

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

Isolated edges
gwidegree-ergmTerm

Geometrically weighted in-degree distribution
intransitive-ergmTerm

Intransitive triads
ininterval-ergmTerm

Number of dyads whose values are in an interval
gwnsp-ergmTerm

Geometrically weighted non-edgewise shared partner distribution
nearsimmelian-ergmTerm

Near simmelian triads
mm-ergmTerm

Mixing matrix cells and margins
mcmc.diagnostics

Conduct MCMC diagnostics on a model fit
localtriangle-ergmTerm

Triangles within neighborhoods
logLikNull

Calculate the null model likelihood
mutual-ergmTerm

Mutuality
molecule

Synthetic network with 20 nodes and 28 edges
meandeg-ergmTerm

Mean vertex degree
logLik.ergm

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

Range of covariate values for neighbors of a node
m2star-ergmTerm

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

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

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

Main effect of a covariate
nodal_attributes

Specifying nodal attributes and their levels
nodeicov-ergmTerm

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

Factor attribute effect
network.list

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

Number of distinct neighbor types
nodal_attributes-API

Helper functions for specifying nodal attribute levels
nodeocovar-ergmTerm

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

Nodal attribute mixing
nodeifactordistinct-ergmTerm

Number of distinct in-neighbor types
nodeicovrange-ergmTerm

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

Factor attribute effect for in-edges
nodematch-ergmTerm

Uniform homophily and differential homophily
odegree-ergmTerm

Out-degree
nodeocov-ergmTerm

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

Out-degree range
observed-ergmConstraint

Preserve the observed dyads of the given network
odegrees-ergmConstraint

Preserve outdegree for directed networks
opentriad-ergmTerm

Open triads
nvattr.copy.network

Copy network- and vertex-level attributes between two network objects
odegree1.5-ergmTerm

Out-degree to the 3/2 power
odegreedist-ergmConstraint

Preserve the outdegree distribution
nodeofactordistinct-ergmTerm

Number of distinct out-neighbor types
nodeofactor-ergmTerm

Factor attribute effect for out-edges
nodeocovrange-ergmTerm

Range of covariate values for out-neighbors of a node
nparam

Length of the parameter vector associated with an object or with its terms.
predict.formula

ERGM-based tie probabilities
nsp-ergmTerm

Directed non-edgewise shared partners
ostar-ergmTerm

k-Outstars
param_names

Names of the parameters associated with an object.
sampson

Cumulative network of positive affection within a monastery as a "network" object
rank_test.ergm

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

Receiver effect
san

Generate networks with a given set of network statistics
simmelianties-ergmTerm

Ties in simmelian triads
randomtoggle-ergmProposal

Propose a randomly selected dyad to toggle
simulate.ergm

Draw from the distribution of an Exponential Family Random Graph Model
search.ergmTerms

Search ERGM terms, constraints, references, hints, and proposals
sender-ergmTerm

Sender effect
simmelian-ergmTerm

Simmelian triads
shrink_into_CH

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

Number of ties between actors with similar attribute values
simulate.formula

A simulate Method for formula objects that dispatches based on the Left-Hand Side
summary.ergm

Summarizing ERGM Model Fits
summary.ergm_model

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

Sum of dyad values (optionally taken to a power)
strat-ergmHint

Stratify Proposed Toggles by Mixing Type on a Vertex Attribute
rlebdm

RLE-Compressed Boolean Dyad Matrix
samplk

Longitudinal networks of positive affection within a monastery as a "network" object
transitiveties-ergmTerm

Transitive ties
sociality-ergmTerm

Undirected degree
sparse-ergmHint

Sparse network
transitive-ergmTerm

Transitive triads
transitiveweights-ergmTerm

Transitive weights
triadcensus-ergmTerm

Triad census
twopath-ergmTerm

2-Paths
update.network

Update the edges in a network based on a matrix
ttriple-ergmTerm

Transitive triples
tripercent-ergmTerm

Triangle percentage
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.
snctrl

Statnet Control
smallerthan-ergmTerm

Number of dyads with values strictly smaller than a threshold
triadic-ergmHint

Network with strong clustering (triad-closure) effects
triangle-ergmTerm

Triangles
summary.formula

Calculation of network or graph statistics or other attributes specified on a formula
wtd.median

Weighted Median
summary_formula

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

Three-trails
spectrum0.mvar

Multivariate version of coda's spectrum0.ar().
.spcache.net-ergmAuxiliary

Shared Partner Cache
to_ergm_Cdouble

Methods to serialize objects into numeric vectors for passing to the C side.
CondB2Degree-ergmProposal

MHp for b2degree constraints
B-ergmTerm

Wrap binary terms for use in valued models
Bernoulli-ergmReference

Bernoulli reference
CondDegree-ergmProposal

MHp for degree constraints
CondDegreeMix-ergmProposal

MHp for degree mix constraints
CondInDegree-ergmProposal

MHp for idegree constraints
CondInDegreeDist-ergmProposal

MHp for idegreedist constraints
CondB1Degree-ergmProposal

MHp for b1degree constraints
CondDegreeDist-ergmProposal

MHp for degreedist constraints
DiscUnif2-ergmProposal

TODO
DiscUnifNonObserved-ergmProposal

TODO
CondOutDegree-ergmProposal

MHp for odegree constraints
DistRLE-ergmProposal

TODO
ConstantEdges-ergmProposal

MHp for edges constraints
DiscUnif-ergmProposal

TODO
BDStratTNT-ergmProposal

TNT proposal with degree bounds, stratification, and a blocks constraint