gofN {ergm.multi}R Documentation

Linear model diagnostics for multinetwork linear models

Description

gofN() performs a simulation to obtain Pearson residuals for the multivariate linear model for ERGM parameters, which can then be used for a variety of diagnostics and diagnostic plots developed by Krivitsky et al. (2023).

Usage

gofN(
  object,
  GOF = NULL,
  subset = TRUE,
  control = control.gofN.ergm(),
  save_stats = FALSE,
  ...
)

## S3 method for class 'gofN'
x[i, j, ..., drop = FALSE]

## S3 method for class 'gofN'
augment(x, ...)

## S3 method for class 'gofN'
summary(object, by = NULL, ...)

Arguments

object

an ergm object.

GOF

a one-sided ergm formula specifying network statistics whose goodness of fit to test, or NULL; if NULL, uses the original model.

subset

argument for the N term.

control

See control.gofN.ergm().

save_stats

If TRUE, save the simulated network statistics; defaults to FALSE to save memory and disk space.

...

additional arguments to functions (simulate.ergm() and summary.ergm_model()) for the constructor.

x

a gofN object.

i

for the indexing operator, index of statistics to be kept in the subset.

j

for the indexing operator, index of networks to be kept in the subset.

drop

whether the indexing operator should drop attributes and return simply a list.

by

a numeric or character vector, or a formula whose RHS gives an expression in terms of network attributes, used as a grouping variable for summarizing the values.

Value

An object of class gofN: a named list containing a list for every statistic in the specified GOF formula with the following elements vectors of length equal to the number of subnetworks:

observed

For completely observed networks, their value of the statistic. For partially observed networks, the expected value of their imputations under the model.

fitted

Expected value of the statistic under the model.

var

Variance of the statistic under the model.

var.obs

Conditional variance under imputation statistic.

pearson

The Pearson residual computed from the above.

stats, stats.obs

If save_stats control parameter is TRUE, the simulated statistics.

In addition, the following attr-style attributes are included:

nw

The observed multinetwork object.

subset

A logical vector giving the subset of networks that were used.

control

Control parameters passed.

Methods (by generic)

References

Krivitsky PN, Coletti P, Hens N (2023). “A Tale of Two Datasets: Representativeness and Generalisability of Inference for Samples of Networks.” Journal of the American Statistical Association, 118(544), 2213-2224. doi:10.1080/01621459.2023.2242627.

See Also

plot.gofN() and autoplot.gofN() for plotting gofN objects to make residual plots; ergm::gof() for single-network goodness-of-fit simulations in ergm

Examples

data(samplk)
monks <- Networks(samplk1, samplk2, samplk3,samplk1, samplk2, samplk3,samplk1, samplk2, samplk3)
fit <- ergm(monks~N(~edges+nodematch("group")))
fit.gof <- gofN(fit) # GOF = original model
summary(fit.gof)
plot(fit.gof)
fit.gof <- gofN(fit, GOF=~triangles)
summary(fit.gof)
plot(fit.gof)


samplk1[1,]<-NA
samplk2[,2]<-NA
monks <- Networks(samplk1, samplk2, samplk3,samplk1, samplk2, samplk3,samplk1, samplk2, samplk3)
fit <- ergm(monks~N(~edges+nodematch("group")))
fit.gof <- gofN(fit) # GOF = original model
summary(fit.gof)
plot(fit.gof)
fit.gof <- gofN(fit, GOF=~triangles)
summary(fit.gof)
plot(fit.gof)
plot(fit.gof, against=~log(.fitted)) # Plot against transformed fitted values.


### If 'ggplot2' and 'ggrepel' are installed, illustrate the autoplot() method.
if(require("ggplot2") && requireNamespace("ggrepel")){
  autoplot(fit.gof)
}

# Default is good enough in this case, but sometimes, we might want to set it higher. E.g.,
## Not run: 
fit.gof <- gofN(fit, GOF=~edges, control=control.gofN.ergm(nsim=400))

## End(Not run)


### If 'generics' is installed, illustrate the augment() method.
if(require("generics")){
  augment(fit.gof)
}


[Package ergm.multi version 0.2.1 Index]