Skip to contents

Computes draw-level averages of MCMC snap indicators over selected actors and years. The result is useful for system-level rupture indices and focal-actor rupture indices. Fits should be run with keep_snap_draws = "draws" for posterior uncertainty. If only snap_prob is present, the function returns a single score row and warns that intervals cannot be read as posterior intervals.

Usage

snap_index_draws(fit, actors = NULL, years = NULL, side = c("u", "v"))

Arguments

fit

a lame fit with snap-shift MCMC output, run with retained snap draws for posterior uncertainty.

actors

optional actor names or indices. Default uses every actor on the selected side.

years

optional year/period names or indices. Default uses every period.

side

"u" for sender/row-side snap indicators or "v" for receiver/column-side indicators.

Value

A data frame with columns draw, year, side, n_actors, and snap_index.

Examples

set.seed(1)
n <- 12; Tt <- 3
Y <- lapply(seq_len(Tt), function(t) {
  m <- matrix(rnorm(n * n), n, n); diag(m) <- NA; m
})
# chains = 1 keeps the example short; the default runs two chains and compares them
fit <- lame(Y, R = 1, dynamic_uv = TRUE, dynamic_uv_kind = "snap",
            keep_snap_draws = "draws",
            nscan = 20, burn = 5, odens = 1, verbose = FALSE, plot = FALSE, chains = 1)
draws <- snap_index_draws(fit, side = "u")
head(draws)
#>    draw year side n_actors snap_index
#> 1 draw1   t1    u       12         NA
#> 2 draw2   t1    u       12         NA
#> 3 draw3   t1    u       12         NA
#> 4 draw4   t1    u       12         NA
#> 5 draw5   t1    u       12         NA
#> 6 draw6   t1    u       12         NA