ergmito_gof {ergmito} | R Documentation |
Goodness of Fit diagnostics for ERGMito models
Description
Goodness of Fit diagnostics for ERGMito models
Usage
gof_ergmito(
object,
GOF = NULL,
GOF_update = NULL,
probs = c(0.05, 0.95),
sim_ci = FALSE,
R = 50000L,
ncores = 1L,
...
)
## S3 method for class 'ergmito_gof'
plot(
x,
y = NULL,
main = NULL,
sub = NULL,
tnames = NULL,
sort_by_ci = FALSE,
...
)
Arguments
object |
An object of class ergmito. |
GOF |
Formula. Additional set of parameters to perform the GOF. |
GOF_update |
Formula. See the section on model updating in |
probs |
Numeric vector. Quantiles to plot (see details). |
sim_ci |
Logical scalar. If |
R |
Integer scalar. Number of simulations to generate (passed to sample).
This is only used if |
ncores |
Integer scalar. Number of cores to use for parallel computations (currently ignored). |
... |
Further arguments passed to stats::quantile. |
x |
An object of class |
y |
Ignored. |
main , sub |
Title and subtitle of the plot (see graphics::title). |
tnames |
A named character vector. Alternative names for the terms. |
sort_by_ci |
Logical scalar. When |
Details
The Goodness of Fit function uses the fitted ERGMito to calculate a given confidence interval for a set of sufficient statistics. By default (and currently the only available option), this is done on the sufficient statistics specified in the model.
In detail, the algorithm is executed as follow:
For every network in the list of networks do:
Calculate the probability of observing each possible graph in its support using the fitted model.
If
sim_ci = TRUE
, drawR
samples from each set of parameters using the probabilities computed. Then using thequantile
function, calculate the desired quantiles of the sufficient statistics. Otherwise, compute the quantiles using the analytic quantiles using the full distribution.'
The plot method is particularly convenient since it graphically shows whether the target statistics of the model (observed statistics) fall within the simulated range.
The print method tries to copy (explicitly) the print method of the
gof
function from the ergm
R package.
Value
An object of class ergmito_gof
. This is a list with the following
components:
-
ci
A list of matrices of lengthnnets(object)
with the corresponding confidence intervals for the statistics of the model. -
target_stats
A matrix of the target statistics. -
ergmito.probs
A list of numeric vectors of lengthnnets(object)
with the probabilities associated to each possible structure of network. -
probs
The value passed viaprobs
. -
model
The fitted model. -
term_names
Character vector. Names of the terms used in the model. -
quantile.args
A list of the values passed via...
.
Examples
# Fitting the fivenets model
data(fivenets, package = "ergmito")
fit <- ergmito(fivenets ~ edges + nodematch("female"))
# Calculating the gof
ans <- gof_ergmito(fit)
# Looking at the results
ans
plot(ans)