% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sequence-latent-models.R
\name{decode_sequence_states}
\alias{decode_sequence_states}
\title{Decode hidden states from a fitted HMM}
\usage{
decode_sequence_states(
  model,
  data = NULL,
  sequence_id_col = "sequence_id",
  order_col = "sequence_order",
  state_col = "state",
  method = c("viterbi", "posterior"),
  component = NULL
)
}
\arguments{
\item{model}{A fitted single HMM or HMM mixture.}

\item{data}{Optional new long-format data. Training sequences are used when
omitted.}

\item{sequence_id_col, order_col, state_col}{Sequence columns for new data.}

\item{method}{\code{"viterbi"} or \code{"posterior"}.}

\item{component}{Mixture component to decode. When omitted for a mixture,
each sequence uses its highest-responsibility component.}
}
\value{
A long data frame containing decoded latent states and posterior
probabilities where available.
}
\description{
Decode hidden states from a fitted HMM
}
\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
)
model <- fit_sequence_hmm(sequences, 2L, max_iter = 5L)
decode_sequence_states(model)

}
