Skip to contents

For a fitted lame object, computes a network statistic (density, reciprocity, or transitivity) at each observed period, fits a least-squares linear trend on period index, and compares the observed slope to slopes from posterior-predictive replicates. The two-sided value is min(1, 2 * min(p_up, p_down)), where both empirical tails include ties. The value runs from 0 (observed slope in the extreme tail) to 1 (observed slope central in the predictive distribution).

Usage

gof_temporal(
  fit,
  stat = c("auto", "density", "mean", "reciprocity", "transitivity"),
  n_rep = 500,
  seed = NULL
)

Arguments

fit

A fitted lame object.

stat

One of "auto" (default: density for binary and ordinal fits, otherwise mean), "density", "mean", "reciprocity", or "transitivity". Density is the fraction of nonzero observed cells. Mean is the mean observed value. Unipartite checks exclude self ties; square bipartite checks retain diagonal cells. Reciprocity requires directed unipartite data; transitivity requires unipartite data. Gaussian density and nonzero transitivity are refused; use mean or weighted reciprocity for continuous outcomes.

n_rep

Number of posterior-predictive replicates to draw (each replicate is a full \(T\)-period network). Must be an integer at least 2.

seed

Optional RNG seed.

Value

A list with

  • stat (chosen statistic name),

  • slope_obs (observed slope of stat on period index),

  • slope_rep (length-n_rep vector of replicate slopes),

  • p_pp (two-sided posterior-predictive p-value),

  • stat_obs_by_t, stat_rep_by_t (per-period statistics),

  • n_rep (number of replicate networks drawn),

  • degenerate (TRUE when the replicate slopes have no spread or a statistic is undefined, in which case p_pp is NA),

  • reason and n_undefined describe an unestimated check,

  • replication_method and draw_index identify joint draws

Details

Observed and replicated statistics use the same actor labels and observed cells in every period. Transitivity counts only fully observed triples. Joint posterior draws are required; missing storage is refused. Fit with posterior_options(save_ab = TRUE, save_UV = TRUE, thin_ab = 1, thin_UV = 1), omitting latent storage at rank zero. A constant observed series is still tested when the predictive slopes vary.

Examples

# \donttest{
data(YX_bin_list)
# chains = 1 keeps the example short; the default runs two chains and compares them
fit <- lame(lapply(YX_bin_list$Y, function(y) 1 * (y > 0)), YX_bin_list$X, family = "binary", R = 0,
            dynamic_beta = "dyad",
            posterior_opts = posterior_options(save_ab = TRUE, thin_ab = 1),
            nscan = 60, burn = 15, odens = 5, verbose = FALSE, chains = 1)
gof_temporal(fit, stat = "density", n_rep = 50)
#> 
#> ── Temporal-trend posterior-predictive check ──
#> 
#> • Statistic: "density"
#> • Observed slope (per-period): -0.000694
#> • Replicates: 50
#> • Posterior-predictive p-value (two-sided): 0.84
#> Observed temporal trend is well covered by the fitted model.
# }