ergm
package is capable of fitting a wide range of
exponential random network models, in which
the probability of a given network, $y$, on a set of nodes is
$\exp(\theta{\cdot}g(y))/c(\theta)$, where
$g(y)$ is a vector of network statistics,
$\theta$ is a parameter vector of the same length and $c(\theta)$ is the
normalizing constant for the distribution.
The ergm
function fits these models when they are expressed
via an Rformula
object, of the form
y ~
,
where y
is a network object or a matrix that can be
coerced to a network object.
To create a
network object in R, use the network()
function,
then add nodal attributes to it using the %v%
operator if necessary. The ergm
package contains a wide range of terms.
For the details on the possible
, see ergm-terms
.
This package can be modified by users to add user-defined terms to ergm
models.
The terms can be used throughout the ergm
package
and behave identically to the supplied terms.
ergm
C
program that generates
the sample of graph statistics using MCMC. This sample is then returned
to R, which then approximates the MLE.ergmuserterms
package is available from the statnet
website (The code contains some simple examples and templates. These include:
m2star
kstar(2)
. This
option adds one statistic to the model, equal to the
number of mixed-2-stars in the network, defined as a
pair of edges ${(i{\rightarrow}j), (j{\rightarrow}k)}.$
} testme
edges
is isomorphic to kstar(1)
; for
directed networks, edges
is isomorphic to both ostar(1)
and istar(1)
. }
library(ergmuserterms)
data(sampson)
monk.fit <- ergm(samplike~m2star)
summary(monk.fit)
monk.fit <- ergm(samplike ~ m2star + testme)
summary(monk.fit)
Run the code above in your browser using DataLab