fit_higher_order_transition_model: Fit a higher-order transition model

View source: R/sequence-networks.R

fit_higher_order_transition_modelR Documentation

Fit a higher-order transition model

Description

Fit a higher-order transition model

Usage

fit_higher_order_transition_model(
  data,
  sequence_id_col = "sequence_id",
  order_col = "sequence_order",
  state_col = "state",
  order = 2L,
  smoothing = 0.5,
  backoff = TRUE,
  context_separator = " > "
)

Arguments

data

Long-format sequence data.

sequence_id_col, order_col, state_col

Sequence columns.

order

Context order.

smoothing

Additive smoothing over observed next states.

backoff

Retain lower-order context tables for prediction backoff.

context_separator

Context separator.

Value

An object of class gp3_higher_order_transition_model.

Examples

sequences <- data.frame(
  sequence_id = rep(c("s1", "s2", "s3", "s4"), each = 4L),
  sequence_order = rep(1:4, times = 4L),
  state = c("A", "B", "C", "D", "A", "B", "C", "C",
            "D", "C", "B", "A", "D", "C", "A", "A"),
  group = rep(c("g1", "g2"), each = 8L),
  stringsAsFactors = FALSE
)
fit_higher_order_transition_model(sequences, order = 2L)


gp3sequences documentation built on Aug. 23, 2026, 5:10 p.m.