extract_edges: Extract Edge List with Weights

View source: R/extraction.R

extract_edgesR Documentation

Extract Edge List with Weights

Description

Extract an edge list from a TNA model, representing the network as a data frame of from-to-weight tuples.

Usage

extract_edges(model, threshold = 0, include_self = FALSE, sort_by = "weight")

Arguments

model

A TNA model object or a matrix of weights.

threshold

Numeric. Minimum weight to include an edge. Default: 0.

include_self

Logical. Whether to include self-loops. Default: FALSE.

sort_by

Character. Column to sort by: "weight" (descending), "from", "to", or NULL for no sorting. Default: "weight".

Details

This function converts the transition matrix into an edge list format, which is useful for visualization, analysis with igraph, or export to other network tools.

Value

A data frame with columns:

from

Source state name.

to

Target state name.

weight

Edge weight (transition probability).

See Also

extract_transition_matrix for the full matrix, build_network for network estimation.

Examples

seqs <- data.frame(V1 = c("A","B","A"), V2 = c("B","A","C"), V3 = c("A","C","B"))
net <- build_network(seqs, method = "relative")
edges <- extract_edges(net, threshold = 0.05)
head(edges)


Nestimate documentation built on April 20, 2026, 5:06 p.m.