mogen_transitions: Extract Transition Table from a MOGen Model

View source: R/mogen.R

mogen_transitionsR Documentation

Extract Transition Table from a MOGen Model

Description

Returns a data frame of all transitions at a given Markov order, sorted by count (descending). Each row shows the full path as a readable sequence of states, along with the observed count and transition probability.

Usage

mogen_transitions(x, order = NULL, min_count = 1L)

Arguments

x

A net_mogen object from build_mogen().

order

Integer. Which order's transitions to extract. Defaults to the optimal order selected by the model.

min_count

Integer. Minimum observed count to include (default 1). Use this to filter out rare transitions that have unreliable probabilities.

Details

At order k, each edge in the De Bruijn graph represents a (k+1)-step path. For example, at order 2, the edge from node "AI -> FAIL" to node "FAIL -> SOLVE" represents the three-step path AI -> FAIL -> SOLVE. The path column reconstructs this full sequence for readability.

Value

A data frame with columns:

path

The full state sequence (e.g., "AI -> FAIL -> SOLVE").

count

Number of times this transition was observed.

probability

Transition probability P(to | from).

from

The context / conditioning states (k-gram source node).

to

The predicted next state.

Examples

seqs <- list(c("A","B","C","D"), c("A","B","C","A"), c("B","C","D","A"))
mg <- build_mogen(seqs, max_order = 2)
mogen_transitions(mg, order = 1)


trajs <- list(c("A","B","C","D"), c("A","B","D","C"),
              c("B","C","D","A"), c("C","D","A","B"))
m <- build_mogen(trajs, max_order = 3)
mogen_transitions(m, order = 1)



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