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.
gof(object, ...)# S3 method for ergm
gof(
object,
...,
coef = coefficients(object),
GOF = NULL,
constraints = object$constraints,
control = control.gof.ergm(),
verbose = FALSE
)
# S3 method for formula
gof(
object,
...,
coef = NULL,
GOF = NULL,
constraints = ~.,
basis = eval_lhs.formula(object),
control = NULL,
unconditional = TRUE,
verbose = FALSE
)
# S3 method for gof
print(x, ...)
# S3 method for gof
plot(
x,
...,
cex.axis = 0.7,
plotlogodds = FALSE,
main = "Goodness-of-fit diagnostics",
normalize.reachability = FALSE,
verbose = FALSE
)
gof()
, gof.ergm()
, and
gof.formula()
return an object of class gof.ergm
, which inherits from class gof
. This
is a list of the tables of statistics and \(p\)-values. This is typically
plotted using plot.gof()
.
Either a formula or an ergm
object.
See documentation for ergm()
.
Additional arguments, to be passed to lower-level functions.
When given either a formula or an object of class ergm,
coef
are the parameters from which the sample is drawn. By default
set to a vector of 0.
formula; an 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,
“idegree” and/or “odegree” for directed graphs, and “b1degree” and “b2degree” for bipartite undirected graphs), geodesic
distances (“distance”), shared partner distributions
(“espartners” and “dspartners”), the triad census
(“triadcensus”), and the terms of the original model
(“model”). The default formula for undirected networks is ~
degree + espartners + distance + model
, and the default formula for
directed networks is ~ idegree + odegree + espartners + distance +
model
. By default a “model” term is added to the formula. It is a
very useful overall validity check and a reminder of the statistical
variation in the estimates of the mean value parameters. To omit the
“model” term, add “- model” to the formula.
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.
A list of control parameters for algorithm tuning,
typically constructed with control.gof.formula()
or control.gof.ergm()
, which have different
defaults. Their documentation gives the the list of recognized
control parameters and their meaning. The more generic utility
snctrl()
(StatNet ConTRoL) also provides argument completion
for the available control functions and limited argument name
checking.
A logical or an integer to control the amount of
progress and diagnostic information to be printed. FALSE
/0
produces minimal output, with higher values producing more
detail. Note that very high values (5+) may significantly slow
down processing.
a value (usually a network
) to override the LHS of the formula.
logical; if TRUE
, the simulation is
unconditional on the observed dyads. if not TRUE
, the simulation is
conditional on the observed dyads. This is primarily used internally when
the network has missing data and a conditional GoF is produced.
an object of class gof
for printing or plotting.
Character expansion of the axis labels relative to that for the plot.
Plot the odds of a dyad having given characteristics (e.g., reachability, minimum geodesic distance, shared partners). This is an alternative to the probability of a dyad having the same property.
Title for the goodness-of-fit plots.
Should the reachability proportion be normalized to make it more comparable with the other geodesic distance proportions.
gof(ergm)
: Perform simulation to evaluate goodness-of-fit for
a specific ergm()
fit.
gof(formula)
: Perform simulation to evaluate goodness-of-fit for
a model configuration specified by a formula
, coefficient,
constraints, and other settings.
print(gof)
: print.gof()
summaries the diagnostics such as the
degree distribution, geodesic distances, shared partner
distributions, and reachability for the goodness-of-fit of
exponential family random graph models. (summary.gof
is a deprecated
alias that may be repurposed in the future.)
plot(gof)
: plot.gof()
plots diagnostics such as the degree
distribution, geodesic distances, shared partner distributions, and
reachability for the goodness-of-fit of exponential family random graph
models.
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.
For GOF = ~model
, the model's observed sufficient statistics are
plotted as quantiles of the simulated sample. In a good fit, the observed
statistics should be near the sample median (0.5).
By default, the sample consists of 100 simulated networks, but this sample
size (and many other settings) can be changed using the control
argument described above.
ergm()
, network()
, simulate.ergm()
, summary.ergm()
# \donttest{
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), coef=c(-1.6339, 0.0049))
plot(gofflo2)
# }
Run the code above in your browser using DataLab