certainty: Analytic certainty of network edges (Bayesian...

View source: R/certainty.R

certaintyR Documentation

Analytic certainty of network edges (Bayesian Dirichlet-Multinomial)

Description

Closed-form alternative to bootstrap_network for transition networks. Models the outgoing transitions from each state as a Dirichlet-Multinomial process: with a Jeffreys prior the posterior for state i is \mathrm{Dirichlet}(c_i + \mathrm{prior}), so each edge is marginally Beta and its posterior mean, standard deviation, credible interval and stability decision are available analytically. No resampling, so it runs in microseconds.

The return value has the same structure as bootstrap_network (same slots and summary columns) and carries class c("net_certainty", "net_bootstrap"), so summary() and any code that consumes a net_bootstrap object work unchanged.

Usage

certainty(
  x,
  prior = 0.5,
  ci_level = 0.05,
  inference = c("stability", "threshold"),
  consistency_range = c(0.75, 1.25),
  edge_threshold = NULL
)

Arguments

x

A netobject from build_network using a transition-probability method ("relative" / "tna"), or a netobject_group.

prior

Numeric. Dirichlet prior concentration added to every cell (default 0.5, the Jeffreys prior).

ci_level

Numeric in (0,1). Tail level for credible intervals and the stability decision (default 0.05, i.e. a 95\ match bootstrap_network().

inference

Character. "stability" (default) tests whether the posterior keeps the edge within a multiplicative consistency_range of its weight; "threshold" tests whether the edge exceeds edge_threshold.

consistency_range

Numeric vector of length 2. Multiplicative bounds for stability inference (default c(0.75, 1.25)).

edge_threshold

Numeric or NULL. Fixed threshold for inference = "threshold". If NULL, defaults to the 10th percentile of non-zero edge weights.

Details

Certainty (this function), stability (bootstrap_network) and reliability (reliability) answer different questions about an edge: how precisely it is pinned down by the observed counts, whether it survives resampling the sequences, and whether it is consistent across split-halves. Certainty and stability agree on homogeneous data; certainty is over-confident when the data are a mixture of latent classes, because it treats transitions clustered within a sequence as independent.

Value

An object of class c("net_certainty", "net_bootstrap") with the same fields as bootstrap_network: original, mean, sd, p_values, significant, ci_lower, ci_upper, cr_lower, cr_upper, summary, model, method, params, ci_level, inference, consistency_range, edge_threshold, plus prior and iter = NA (no iterations).

References

Johnston, L. & Jendoubi, T. (2026). How Delivery Mode Reshapes Resource Engagement: A Bayesian Differential Network Analysis. TNA Workshop 2026.

See Also

bootstrap_network, bayes_compare, network_reliability

Examples

seqs <- data.frame(V1 = c("A","B","A","C","B"), V2 = c("B","C","B","A","C"),
                   V3 = c("C","A","C","B","A"))
net <- build_network(seqs, method = "relative")
cert <- certainty(net)
cert
summary(cert)


Nestimate documentation built on July 11, 2026, 1:09 a.m.