ergm
is used to fit exponential-family random graph
models (ERGMs), 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 (usually $h(y)=1$),
$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. This page describes the constraints (the networks $y$ for which $h(y)>0$)
that are included with the
ergm
package. Other packages may add new
constraints.
constraints
term bd
. Let's consider the simple cases first.
Suppose you want to condition on the total number of degrees
regardless of attributes. That is, if you had a survey that asked
respondents to name three alters and no more, then you might want to
limit your maximal outdegree to three without regard to any of the
alters' attributes. The argument is then: constraints=~bd(maxout=3)
Similar calls are used to restrict the number of indegrees
(maxin
), the minimum number of outdegrees
(minout
), and the minimum number of indegrees
(minin
). You can also set ego specific limits. For example: constraints=bd(maxout=rep(c(3,4),c(36,35)))
limits the first 36 to 3 and the other 35 to 4 outdegrees. Multiple restrictions can be combined. bd
is very flexible.
In general, the bd
term can contain up to five arguments: bd(attribs=attribs, maxout=maxout, maxin=maxin, minout=minout, minin=minin)Omitted arguments are unrestricted, and arguments of length 1 are replicated out to all nodes (as above). If an individual entry in
maxout
,..., minin
is NA
then
no restriction of that kind is applied to that actor. In general, attribs
is a matrix of the attributes on
which we are conditioning. The dimensions of attribs
are n_nodes
rows by attrcount
columns, where
attrcount
is the number of distinct attribute values
on which we want to condition (i.e., a separate column is
required for male and female if we want to condition on
the number of ties to both male and female partners).
The value of attribs[n, i]
, therefore, is TRUE
if node n
has attribute value i, and FALSE
otherwise.
(Note that, since each column represents only a single value
of a single attribute, the values of this matrix are all
Boolean (TRUE
or FALSE
).) It is important to
note that attribs
is a matrix of nodal attributes,
not alter attributes. So, for instance, if we wanted to construct an attribs
matrix
with two columns, one each for male and female attribute
values (we are conditioning on these values of the attribute
sex), and the attribute sex is represented in ads.sex as
an n_node
-long vector of 0s and 1s (men and women),
then our code would look as follows: # male column: bit vector, TRUE for males attrsex1 <- (ads.sex == 0) # female column: bit vector, TRUE for females attrsex2 <- (ads.sex == 1) # now create attribs matrix attribs <- matrix(ncol=2,nrow=71, data=c(attrsex1,attrsex2))
maxout
is a matrix of alter attributes, with the same
dimensions as the attribs
matrix. maxout
is n_nodes
rows by attrcount
columns. The value of maxout[n,i]
,
therefore, is the maximum number of outdegrees permitted
from node n
to nodes with the attribute i
(where a NA
means there is no maximum). For example: if we wanted to create a maxout
matrix to work
with our attribs
matrix above, with a maximum from every
node of five outedges to males and five outedges to females,
our code would look like this: # every node has maximum of 5 outdegrees to male alters maxoutsex1 <- c(rep(5,71)) # every node has maximum of 5 outdegrees to female alters maxoutsex2 <- c(rep(5,71)) # now create maxout matrix maxout <- cbind(maxoutsex1,maxoutsex2)The
maxin
, minout
, and minin
matrices
are constructed exactly like the maxout
matrix,
except for the maximum allowed indegree, the minimum allowed
outdegree, and the minimum allowed indegree, respectively.
Note that in an undirected network, we only look at the outdegree
matrices; maxin
and minin
will both be ignored
in this case. Goodreau SM, Handcock MS, Hunter DR, Butts CT, Morris M (2008a). A statnet Tutorial. Journal of Statistical Software, 24(8). http://www.jstatsoft.org/v24/i08/.
Hunter, D. R. and Handcock, M. S. (2006) Inference in curved exponential family models for networks, Journal of Computational and Graphical Statistics.
Hunter DR, Handcock MS, Butts CT, Goodreau SM, Morris M (2008b). ergm: A Package to Fit, Simulate and Diagnose Exponential-Family Models for Networks. Journal of Statistical Software, 24(3). http://www.jstatsoft.org/v24/i03/.
Krivitsky PN (2012). Exponential-Family Random Graph Models for Valued Networks. Electronic Journal of Statistics, 2012, 6, 1100-1128. \Sexpr[results=rd,stage=build]{tools:::Rd_expr_doi("#1")}10.1214/12-EJS696http://doi.org/10.1214/12-EJS696doi:\ifelse{latex}{\out{~}}{ }latex~ 10.1214/12-EJS696
Morris M, Handcock MS, Hunter DR (2008). Specification of Exponential-Family Random Graph Models: Terms and Computational Aspects. Journal of Statistical Software, 24(4). http://www.jstatsoft.org/v24/i04/.