Skip to contents

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.

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.

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.

Examples

# \donttest{
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)
#>     path count probability from to
#> 1 A -> B     3      1.0000    A  B
#> 2 C -> D     3      1.0000    C  D
#> 3 D -> A     2      0.6667    D  A
#> 4 B -> C     2      0.6667    B  C
#> 5 D -> C     1      0.3333    D  C
#> 6 B -> D     1      0.3333    B  D
# }