ergmm {latentnet} | R Documentation |
Fit a Latent Space Random Graph Model
Description
ergmm()
is used to fit latent space and latent space cluster
random network models, as described by Hoff, Raftery and Handcock (2002),
Handcock, Raftery and Tantrum (2005), and Krivitsky, Handcock, Raftery, and
Hoff (2009). ergmm()
can return either a Bayesian model fit or
the two-stage MLE.
Usage
ergmm(
formula,
response = NULL,
family = "Bernoulli",
fam.par = NULL,
control = control.ergmm(),
user.start = list(),
prior = ergmm.prior(),
tofit = c("mcmc", "mkl", "mkl.mbc", "procrustes", "klswitch"),
Z.ref = NULL,
Z.K.ref = NULL,
seed = NULL,
verbose = FALSE
)
Arguments
formula |
An formula object, of the form Note that, as in |
response |
An optional edge attribute that serves as the response
variable. By default, presence (1) or absence (0) of an edge in |
family |
A character vector specifying the conditional distribution of each edge value. See families.ergmm for the currently implemented families. |
fam.par |
For those families that require additional parameters, a list. |
control |
The MCMC parameters that do not affect the posterior
distribution such as the sample size, the proposal variances, and tuning
parameters, in the form of a named list. See |
user.start |
An optional initial configuration parameters for MCMC in the form of a list. By default, posterior mode conditioned on cluster assignments is used. It is permitted to only supply some of the parameters of a configuration. If this is done, the remaining paramters are fitted conditional on those supplied. |
prior |
The prior parameters for the model being fitted in the form of
a named list. See term help for the terms to use. If given, will
override those given in the formula terms, making it useful as a convenient
way to store and reproduce a prior distribution. The list or prior
parameters can also be extracted from an ERGMM fit
object. See |
tofit |
A character vector listing some subset of "pmode", "mcmc",
"mkl", "mkl.mbc", "mle","procrustes", and "klswitch", defaulting to all of
the above, instructing |
Z.ref |
If given, used as a reference for Procrustes analysis. |
Z.K.ref |
If given, used as a reference for label-switching. |
seed |
If supplied, random number seed. |
verbose |
If this is |
Value
ergmm
returns an object of class
ergmm
containing the information about the
posterior.
Specifying fixed effects
Each coefficient for a fixed effect covariate has a normal prior whose
mean and variance are set by the mean
and var
parameters
of the term. For those formula terms that add more than one covariate,
a vector can be given for mean and variance. If not, the vectors given
will be repeated until the needed length is reached.
ergmm
can use model terms implemented for the
ergm
package and via the
ergm.userterms
API (in GitHub repository statnet/ergm.userterms
). See
ergmTerm
for a list of available terms. If you
wish to specify the prior mean and variance, you can add them to
the call. E.g.,
TERMNAME(..., mean=0, var=9)
,
where
...
are the arguments for the ergm
term, will
initialize TERMNAME
with prior mean of 0 and prior variance
of 9.
Some caveats:
-
ergm
has a binary and a valued mode. Regardless of thefamily
used, the binary variant of theergm
term will be used in the linear predictor of the model. -
ergm
does not support modeling self-loops, so terms imported in this way will always have predictorx[i,i]==0
. This should not affect most situations, but if you absolutely must model self-loops and non-self-edges in one term, use the deprecated terms below. -
latentnet
only fits models with dyadic independence. Terms that induce dyadic dependence (e.g.,triangles
) can be used, but then the likelihood of the model will, effectively, be replaced with pseudolikelihood. (Note that under dyadic independence, the two are equal.)
References
Mark S. Handcock, Adrian E. Raftery and Jeremy Tantrum (2002). Model-Based Clustering for Social Networks. Journal of the Royal Statistical Society: Series A, 170(2), 301-354.
Peter D. Hoff, Adrian E. Raftery and Mark S. Handcock (2002). Latent space approaches to social network analysis. Journal of the American Statistical Association, 97(460), 1090-1098.
Pavel N. Krivitsky, Mark S. Handcock, Adrian E. Raftery, and Peter D. Hoff (2009). Representing degree distributions, clustering, and homophily in social networks with latent cluster random effects models. Social Networks, 31(3), 204-213.
Pavel N. Krivitsky and Mark S. Handcock (2008). Fitting Position
Latent Cluster Models for Social Networks with latentnet
. Journal of
Statistical Software, 24(5). doi:10.18637/jss.v024.i05
See Also
network
, summary.ergmm, ergmTerm
, families.ergmm
Examples
#
# Use 'data(package = "latentnet")' to list the data sets in a
#
data(package="latentnet")
#
# Using Sampson's Monk data, lets fit a
# simple latent position model
#
data(sampson)
samp.fit <- ergmm(samplike ~ euclidean(d=2))
#
# See if we have convergence in the MCMC
mcmc.diagnostics(samp.fit)
#
# Plot the fit
#
plot(samp.fit)
#
# Using Sampson's Monk data, lets fit a latent clustering random effects model
#
samp.fit2 <- ergmm(samplike ~ euclidean(d=2, G=3)+rreceiver)
#
# See if we have convergence in the MCMC
mcmc.diagnostics(samp.fit2)
#
# Plot the fit.
#
plot(samp.fit2, pie=TRUE)