Learn R Programming

latentnet (version 0.7-17)

gof.ergmm: Conduct Goodness-of-Fit Diagnostics on a Latent Position or Latent Cluster Position Model

Description

gof computes and plots posterior predictive checks for various networks statistics (e.g., geodesic distance, degree, and reachability) to diagnose the goodness-of-fit of Latent Position or Latent Cluster Position models. See ergmm for more information on these models.

Usage

## S3 method for class 'default':
gof(object,\dots)
## S3 method for class 'ergmm':
gof(object, \dots,
         nsim=100,
         GOF=~degree+espartners+distance,
         verbose=FALSE)

Arguments

object
an ergmm object. See documentation for ergmm.
nsim
The number of posterior draws to use for the posterior predictive checks. This is the size of the sample of networks to be randomly drawn from the posterior distribution specified by the object.
GOF
formula; an Rformula object, of the form ~ specifying the statistics to use to diagnosis the goodness-of-fit of the model. They do not need to be in the model formula specified in formula, and typically
verbose
Provide verbose information on the progress of the simulation.
...
Additional arguments, to be passed to lower-level functions in the future.

Value

  • gof, gof.ergmm, and gof.formula return an object of class gofobject. This is a list of the tables of statistics and posterior ``$p$-values". This is typically plotted using plot.gofobject.

Details

A sample of graphs is randomly drawn from the posterior of the specified model. The first argument is the output of a call to ergmm and the model used for that call is the one evalauted.

A plot of the summary measures is plotted.

See Also

ergmm, network, rergm, summary.ergmm, plot.gofobject

Examples

Run this code
#
# Using Sampson's Monk data, lets fit a 
# simple latent position model
#
data(sampson)
#
# Get the group labels
#
group <- get.vertex.attribute(samplike,"group")
samp.labs <- substr(group,1,1)
#
# Fit the two-dimensional latent social space model 
#
# This may take a few minutes ...
#
samp.fit <- ergmm(samplike ~ latent(k=2), burnin=10000,
                  MCMCsamplesize=2000, interval=30)
#
# Posterior Predictive Checks
gofsamplike <- gof.ergmm(samp.fit, GOF=~idegree + distance)
gofsamplike
#
# Place both on the same page
# with nice margins
#
par(mfrow=c(1,2))
par(oma=c(0.5,2,1,0.5))
#
plot(gofsamplike)
#
# And now the odds 
#
plot(gofsamplike, plotodds=TRUE)
#
# Using Sampson's Monk data, lets 
# fit the two-dimensional clustered latent social space model 
#
# The ngroups parameter fits 3 groups
#
# This may take a few minutes ...
#
samp.fit <- ergmm(samplike ~ latentcluster(k=2, ngroups=3), burnin=10000,
                  MCMCsamplesize=2000, interval=30)
#
# Posterior Predictive Checks
gofsamplike <- gof.ergmm(samp.fit, GOF=~idegree + distance)
gofsamplike
#
plot(gofsamplike)
#
# And now the odds 
#
plot(gofsamplike, plotodds=TRUE)

Run the code above in your browser using DataLab