terms.ergmm {latentnetHRT} | R Documentation |
By way of context, the package statnet
is used to fit linear 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 can return either a maximum pseudo-likelihood estimate or
an approximate MLE based on a Monte Carlo scheme.
For details, see http://www.csde.washington.edu/statnet.
The package latentnetHRT
adds latent variable models
to the traditional exponential random network models. These
latent models are fit using the ergmm
function.
The ergmm
specifies models via: y ~ <model terms>
where y
is a network
object.
This page describes the possible <model terms>
.
ergmm(formula, ...)
y ~ <term 1> + <term 2> ...
,
where y
is a network object or a matrix that can be coerced to a graph
object, and <term 1>
, <term 2>
, 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 set.vertex.attributes()
if necessary.ergmm
function.
The latentnetHRT
package itself allows only three type of terms:
latent
, latentcluster
and latentcov
.
The umbrella ergm
package allows the user to explore a large number
of potential models for their network data in addition to these terms. The
terms currently supported by the program,
and a brief description of each is given in the documentation
terms.ergm
for the ergm
package.
In the formula for the model, the model terms are various function-like
calls, some of which require arguments, separated by +
signs.
The current options are:
latent(k=2, ...)
k
is the dimension of the latent space. For information on the
other arguments look for help on latent
.
latentcluster(k=2, ngroups, ...)
k
is the dimension of the latent space
and ngroups
is the number of clusters in the latent space.
For information on the other arguments look for help on
latentcluster
.
latentcov(cv, attrname=NULL)
cv
is either a matrix of
covariates on each pair of vertices, or a network;
if the latter, optional argument
attrname
provides the name of the edge attribute to
use for edge values. This option adds one statistic to the
model, representing the effect of the given covariate on
the appearance of edges. edgecov
can be called more
than once, to model the effects of multiple covariates.
Peter D. Hoff, Adrian E. Raftery and Mark S. Handcock. Latent space approaches to social network analysis. Journal of the American Statistical Association, Dec 2002, Vol.97, Iss. 460; pg. 1090-1098.
Mark S. Handcock, Adrian E. Raftery and Jeremy Tantrum. Model-Based Clustering for Social Networks. Working Paper Number 46, Center for Statistics and the Social Sciences, University of Washington, April 2005.
ergmm, latent, latentcluster, sna, network, set.vertex.attributes, set.network.attributes, summary.ergm
## Not run: # # Using Sampson's Monk data, lets fit a # simple latent position model # data(sampson) # # Get the group labels samp.labs <- substr(get.vertex.attribute(samplike,"group"),1,1) # samp.fit <- ergmm(samplike ~ latent(k=2), burnin=10000, MCMCsamplesize=2000, interval=30) # # See if we have convergence in the MCMC mcmc.diagnostics(samp.fit) # # Plot the fit # plot(samp.fit,label=samp.labs, vertex.col="group") # # Using Sampson's Monk data, lets fit a latent clustering model # samp.fit <- ergmm(samplike ~ latentcluster(k=2, ngroups=3), burnin=10000, MCMCsamplesize=2000, interval=30) # # See if we have convergence in the MCMC mcmc.diagnostics(samp.fit) # # Lets look at the goodness of fit: # plot(samp.fit,label=samp.labs, vertex.col="group") plot(samp.fit,pie=TRUE,label=samp.labs) plot(samp.fit,density=c(2,2)) plot(samp.fit,contours=5,contour.color="red") plot(samp.fit,density=TRUE,drawarrows=TRUE) ergmm.add.contours(samp.fit,nlevels=8,lwd=2) points(samp.fit$Z.mkl,pch=19,col=samp.fit$class) ## End(Not run)