Skip to contents

Creates diagnostic plots comparing observed network statistics to their posterior predictive distributions. This helps assess whether the model adequately captures important network features.

Usage

gof_plot(
  fit,
  type = c("auto", "static", "longitudinal"),
  statistics = c("sd.row", "sd.col", "dyad.dep", "triad.dep"),
  credible.level = 0.95,
  ncol = 2,
  point.size = 2,
  line.size = 1,
  title = NULL
)

Arguments

fit

An object of class "ame" or "lame" containing GOF statistics

type

Character string: "auto" (default), "static", or "longitudinal". If "auto", determined by model class.

statistics

Character vector specifying which statistics to plot. Default is all four: c("sd.row", "sd.col", "dyad.dep", "triad.dep")

credible.level

Numeric between 0 and 1; credible interval level for longitudinal plots (default 0.95)

ncol

Number of columns for faceted plot layout (default 2)

point.size

Size of points in longitudinal plots (default 2)

line.size

Width of lines in plots (default 1)

title

Optional title for the plot

Value

A ggplot2 object that can be further customized

Details

The function evaluates model fit using four key network statistics:

Standard deviation of row means

Captures variance in out-degree/activity

Standard deviation of column means

Captures variance in in-degree/popularity

Dyadic dependence

Correlation between dyads (reciprocity)

Triadic dependence

Transitivity/clustering in the network

For static models (AME), the function produces histograms comparing the observed statistic (red line) to the posterior predictive distribution.

For longitudinal models (LAME), the function produces time series plots showing the observed statistics over time with posterior predictive intervals.

Good model fit is indicated when:

  • Observed values fall within the posterior predictive distributions

  • No systematic deviations across statistics

  • For longitudinal models, observed values track within the credible bands

Author

Cassy Dorff, Shahryar Minhas, Tosin Salau

Examples

if (FALSE) { # \dontrun{
# Fit an AME model
fit_ame <- ame(Y, X, gof = TRUE)

# Basic GOF plot
gof_plot(fit_ame)

# Plot only degree-related statistics
gof_plot(fit_ame, statistics = c("sd.row", "sd.col"))

# Fit a LAME model
fit_lame <- lame(Y_list, X_list)

# Longitudinal GOF plot with 90% credible intervals
gof_plot(fit_lame, credible.level = 0.90)
} # }