Learn R Programming

latentnet (version 0.7-7)

terms.ergmm: Terms used in Latent position and cluster models for networks

Description

By way of context, the package statnet is used to fit linear exponential random network models, in which the probability of a given network, $g$, on a set of nodes is $\exp(\theta^{T}S(g))/c(\theta)$, where $S(g)$ 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 latentnet 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: g ~ where g is a network object.

This page describes the possible .

The ergmm function

ergmm(formula, ...)

Arguments to ergmm

formula{An Rformula object, of the form g ~ + ..., where g is a network object or a matrix that can be coerced to a graph 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 set.vertex.attributes() if necessary.} ...{Other optional arguments to be used by the ergmm function.}

Possible terms to represent graph statistics

The latentnet 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, ...){Latent position model term. where k is the dimension of the latent space. For information on the other arguments look for help on latent. } latentcluster(k=2, ngroups, ...){Latent position cluster model term. where 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){Covariates for the latent model. 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. }

References

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.

See Also

ergmm, latent, latentcluster, sna, network, set.vertex.attributes, set.network.attributes, summary.ergm

Examples

Run this code
#
# 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)

Run the code above in your browser using DataLab