Learn R Programming

latentnet (version 0.6-0)

mcmc.diagnostics.ergm: Conduct MCMC diagnostics on an ergm fit

Description

This function creates simple diagnostic plots for the MCMC sampled statistics produced from a fit. It also prints the Raftery-Lewis diagnostics, indicates if they are sufficient, and suggests the run length required.

Usage

## S3 method for class 'ergm':
mcmc.diagnostics(object, sample = "sample",
                      smooth=TRUE, r = 0.0125, digits = 6,
                      maxplot = 1000, verbose = TRUE, 
                      mcmc.title = "Summary of MCMC samples", \dots)
ergm.raftery.diag(data, q = 0.025, rmargin = 0.005, s = 0.95, converge.eps = 0.001)

Arguments

object
An object. See documentation for ergm.
sample
The component of object on which the diagnosis is based. The two usual ones are thetasample from the auxiliary sample of the natural parameter and sample the (default) sample of the sufficient statistics
smooth
Draw a smooth line through trace plots
r
Percentile of the distribution to estimate
digits
Number of digits to print
maxplot
Maximum number of statistics to plot
data
an 'mcmc' object, typically the component of object on which the diagnosis is based.
q
the quantile to be estimated.
rmargin
the desired margin of error of the estimate.
s
the probability of obtaining an estimate in the interval (q-r,q+r).
converge.eps
Precision required for estimate of time to convergence.
verbose
If this is TRUE, print out more information about the MCMC runs including lag correlations.
mcmc.title
Figure title for the diagnostic plots.
...
Additional arguments, to be passed to lower-level functions in the future.

Value

  • mcmc.diagnostics.ergm returns a table of Raftery-Lewis diagnostics.

Details

The plots produced are a trace of the sampled output and a density estimate for each variable in the chain.

The Raftery-Lewis diagnostic is a run length control diagnostic based on a criterion of accuracy of estimation of the quantile q. It is intended for use on a short pilot run of a Markov chain. The number of iterations required to estimate the quantile q to within an accuracy of +/- r with probability p is calculated. Separate calculations are performed for each variable within each chain.

In fact, an object contains the matrix of statistics from the MCMC run as component $sample. This matrix is actually an object of class mcmc and can be used directly in the CODA package to assess MCMC convergence. Hence all MCMC diagnostic methods available in coda are available directly. See the examples andthe coda package.

More information can be found by looking at the documentation of ergm.

See Also

ergm, network, coda

Examples

Run this code
#
data(sampson)
#
# test the mcmc.diagnostics function
#
gest <- ergm(samplike ~ latent(k=2))
summary(gest)
#
# Plot the probabilities first
#
mcmc.diagnostics(gest)
#
# Use coda directly
#
library(coda)
#
plot(gest$sample, ask=FALSE)
ergm.raftery.diag(gest$sample, r=0.1)
#
# A full range of diagnostics are available 
# using codamenu()
#

Run the code above in your browser using DataLab