ergm
is used to fit exponential
random graph models, in which
the probability of a given network, $y$, on a set of nodes is
$h(y) \exp\{\eta(\theta) \cdot
g(y)\}/c(\theta)$, where
$h(y)$ is the reference measure (for valued network models),
$g(y)$ is a vector of network statistics for $y$,
$\eta(\theta)$ is a natural parameter vector of the same
length (with $\eta(\theta)=\theta$ for most terms), and $c(\theta)$ is the
normalizing constant for the distribution. The network statistics $g(y)$ are entered as terms in the
function call to ergm
.
This page describes the possible terms (and hence network statistics)
included in ergm
package. Other packages
may add their own terms, and package
ergm.userterms
provides tools
for implementing them.
The current recommendation for any package implementing additional
terms is to create a help file with a name or alias ergm-terms
,
so that help("ergm-terms")
will list ERGM terms available from
all loaded packages.
ergm
are specified by a formula to represent the network and
network statistics. This is done via a formula
, that is,
an R formula object, of the form
y ~ + ...
,
where y
is a network object or a matrix that can be coerced to a
network
object, and
,
, etc, are each terms chosen
from the list given below.
To create a network object in R, use the network
function,
then add nodal attributes to it using the %v%
operator if necessary.ergm
functions such as ergm
and simulate
(for ERGMs) may operate
in two modes: binary and weighted/valued, with the latter activated by
passing a non-NULL value as the response
argument, giving the
edge attribute name to be modeled/simulated. Binary ERGM statistics cannot be used in valued mode and vice versa. However,
a substantial number of binary ERGM statistics --- particularly the
ones with dyadic indepenence --- have simple generalizations to valued
ERGMs, and have been adapted in
ergm
. They have the same form as their
binary ERGM counterparts, with an additional argument: form
, which, at
this time, has two possible values: "sum"
(the default) and
"nonzero"
. The former creates a statistic of the form
$\sum_{i,j} x_{i,j} y_{i,j}$, where $y_{i,j}$ is the value of
dyad $(i,j)$ and $x_{i,j}$ is the term's covariate associated
with it. The latter computes the binary version, with the edge
considered to be present if its value is not 0. Valued version of some binary ERGM terms have an argument
threshold
, which sets the value above which a dyad is conidered
to have a tie. (Value less than or equal to threshold
is
considered a nontie.)transform
and transformname
arguments. transform
should be a function with one argument, taking a data structure of the
same mode as the covariate and returning a similarly structured data
structure, transforming the covariate as needed. For example, nodecov("a", transform=function(x) x^2)
will add a nodal covariate having the square of the value of the nodal attribute
"a"
. transformname
, if given, will be added to the term's name to
help identify it.vignette('ergm-term-crossRef')
and terms can also be searched via search.ergmTerms
.
ergm
package, search.ergmTerms
, ergm
, network
, %v%
, %n%
## Not run:
# ergm(flomarriage ~ kstar(1:2) + absdiff("wealth") + triangle)
#
# ergm(molecule ~ edges + kstar(2:3) + triangle
# + nodematch("atomic type",diff=TRUE)
# + triangle + absdiff("atomic type"))
# ## End(Not run)
Run the code above in your browser using DataLab