gof {ergm}R Documentation

Conduct Goodness-of-Fit Diagnostics on a Exponential Family Random Graph Model

Description

gof calculates p-values for geodesic distance, degree, and reachability summaries to diagnose the goodness-of-fit of exponential family random graph models. See ergm for more information on these models.

Usage

## Default S3 method:
gof(object,...)
## S3 method for class 'formula'
gof(formula, ..., theta0=NULL,
         nsim=100, burnin=10000, interval=1000,
         GOF=NULL,
         constraints=~.,
         control=control.gof.formula(),
         seed=NULL,
         verbose=FALSE)
## S3 method for class 'ergm'
gof(object, ...,
         nsim=100,
         GOF=NULL,
         burnin=10000, interval=1000,
         constraints=NULL,
         control=control.gof.ergm(),
         seed=NULL, 
         theta0=NULL, verbose=FALSE)

Arguments

object

an R object. Either a formula or an ergm object. See documentation for ergm.

formula

formula; An R formula object, of the form y ~ <model terms>, where y is a network object or a matrix that can be coerced to a network object. This specifies the model to simulate from. For the details on the possible <model terms>, see ergm-terms. To create a network object in R, use the network() function, then add nodal attributes to it using the %v% operator if necessary.

theta0

When given either a formula or an object of class ergm, theta0 are the parameters from which the sample is drawn. By default set to a vector of 0.

nsim

The number of simulations to use for the MCMC p-values. This is the size of the sample of graphs to be randomly drawn from the distribution specified by the object on the set of all graphs.

GOF

formula; an R formula object, of the form ~ <model terms> 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 are not. Currently supported terms are the degree distribution (“degree” for undirected graphs, or “idegree” and/or “odegree” for directed graphs), geodesic distances (“distance”), shared partner distributions (“espartners” and “dspartners”), the triad census (“triadcensus”), and the terms of the original model (“model”).

burnin

Number of proposed edge toggles before any MCMC sampling is done. If the model is correct this can be 0. Currently, there is no support for any check of the Markov chain mixing, so burnin should be set to a fairly large number.

interval

Number of proposed edge toggles between sampled statistics. The program prints a warning if too few proposed toggles are being accepted (if the number of proposed toggles between sampled observations ever equals an integral multiple of 100*(1+the number of toggles accepted)).

constraints

A one-sided formula specifying one or more constraints on the support of the distribution of the networks being modeled. See the help for similarly-named argument in ergm for more information. For gof.formula, defaults to unconstrained. For gof.ergm, defaults to the constraints with which object was fitted.

control

A list to control parameters, constructed using control.gof.formula or control.gof.ergm (which have different defaults).

seed

integer; random number integer seed. Defaults to NULL to use whatever the state of the random number generater is at the time of the call.

verbose

Provide verbose information on the progress of the simulation.

...

Additional arguments, to be passed to lower-level functions in the future.

Details

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

A plot of the summary measures is plotted. More information can be found by looking at the documentation of ergm.

For gof.ergm and gof.formula, default behavior depends on the directedness of the network involved; if undirected then degree, espartners, and distance are used as default properties to examine. If the network in question is directed, “degree” in the above is replaced by idegree and odegree.

Value

gof, gof.ergm, and gof.formula return an object of class gofobject. This is a list of the tables of statistics and p-values. This is typically plotted using plot.gofobject.

See Also

ergm, network, simulate.ergm, summary.ergm, plot.gofobject

Examples

data(florentine)
gest <- ergm(flomarriage ~ edges + kstar(2))
gest
summary(gest)

# test the gof.ergm function
gofflo <- gof(gest)
gofflo

# Plot all three on the same page
# with nice margins
par(mfrow=c(1,3))
par(oma=c(0.5,2,1,0.5))
plot(gofflo)

# And now the log-odds
plot(gofflo, plotlogodds=TRUE)

# Use the formula version of gof
gofflo2 <-gof(flomarriage ~ edges + kstar(2), theta0=c(-1.6339, 0.0049))
plot(gofflo2)

[Package ergm version 2.4-3 Index]