latentcluster()
is a term to the function ergmm
to fit a latent postion model to a
given network, $g$.
ergmm
returns a Bayesian model fit based on a Monte Carlo scheme
The default prior specifications are diffuse. An approximate MLE fit is
also returned. The ergmm
specifies models via: g ~ latentcluster(
where g
is a network
object
For the list of possible
, see below.
latentcluster(k=2, ngroups, z.prior.mu=0, z.prior.sd=10, b.delta=0.5,
b.prior.mu=0, b.prior.sd=10,
Sigprior = qchisq(0.05,3),
muSigprior = 2, dirprior=3,
alphaprior=3,
chisqprop = 6, thetaprop=0.1, ...)
ergmm
returns an object of class 'ergmm' that is a list.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.
#
# 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)
#
# 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