% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mogen.R
\name{build_mogen}
\alias{build_mogen}
\title{Build Multi-Order Generative Model (MOGen)}
\usage{
build_mogen(
  data,
  max_order = 5L,
  criterion = c("aic", "bic", "lrt"),
  lrt_alpha = 0.01
)
}
\arguments{
\item{data}{A data.frame (rows = trajectories, columns = time points) or
a list of character/numeric vectors (one per trajectory).}

\item{max_order}{Integer. Maximum Markov order to test (default 5).
Must be a whole number; a non-integer value (e.g. \code{2.7}) is an
error rather than being silently truncated.}

\item{criterion}{Character. Model selection criterion: \code{"aic"}
(default), \code{"bic"}, or \code{"lrt"} (likelihood ratio test).}

\item{lrt_alpha}{Numeric. Significance threshold for LRT (default 0.01).}
}
\value{
An object of class \code{net_mogen} with components:
\describe{
\item{optimal_order}{Selected optimal Markov order.}
\item{criterion}{Which criterion was used for selection.}
\item{orders}{Integer vector of tested orders (0 to max_order).}
\item{aic}{Named numeric vector of AIC values per order.}
\item{bic}{Named numeric vector of BIC values per order.}
\item{log_likelihood}{Named numeric vector of log-likelihoods.}
\item{dof}{Named integer vector of cumulative DOF per model.}
\item{layer_dof}{Named integer vector of per-layer DOF.}
\item{transition_matrices}{List of transition matrices (index 1 = order 0).}
\item{states}{Unique first-order states.}
\item{n_paths}{Number of trajectories.}
\item{n_observations}{Total number of state observations.}
}
}
\description{
Constructs higher-order De Bruijn graphs from sequential trajectory data and
selects the optimal Markov order using AIC, BIC, or likelihood ratio tests.
}
\details{
At order k, nodes are k-tuples of states and edges represent transitions
between overlapping k-tuples. The model tests increasingly complex Markov
orders and selects the one that best balances fit and parsimony.
}
\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)

\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)
print(m)
plot(m)
}

}
\references{
Scholtes, I. (2017). When is a Network a Network? Multi-Order Graphical
Model Selection in Pathways and Temporal Networks. \emph{KDD 2017}.

Gote, C. & Scholtes, I. (2023). Predicting variable-length paths in
networked systems using multi-order generative models. \emph{Applied
Network Science}, 8, 62.
}
