plot.ergm
is the plotting method for ergm
objects.
It plots the MCMC diagnostics via the
mcmc.diagnostics
function.
See ergm
for more information on how to fit these
models.## S3 method for class 'ergm':
plot(x, \dots, mle=FALSE, comp.mat = NULL,
label = NULL, label.col = "black",
xlab, ylab, main, label.cex = 0.8, edge.lwd = 1,
edge.col=1, al = 0.1,
contours=0, density=FALSE, only.subdens = FALSE,
drawarrows=FALSE,
contour.color=1, plotnetwork=FALSE, pie = FALSE, piesize=0.07,
vertex.col=1, vertex.pch=19, vertex.cex=2,
mycol=c("black","red","green","blue","cyan",
"magenta","orange","yellow","purple"),
mypch=15:19, mycex=2:10)
mycol
. Can be
specified as an attribute of the network used in the model.mypch
. Can be specified as an attribute of the network used in
the model. By default it is 15 - a red square.mycex
. Can be
specified as an attribute of the network used in the model.ergm
.#
# The example assumes you have the 'latentnet' package installed.
#
# 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 <- ergm(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 <- ergm(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)
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