% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/decoding_functions.R
\name{stateprobs}
\alias{stateprobs}
\title{Calculate conditional local state probabilities in HMMs}
\usage{
stateprobs(
  delta,
  Gamma,
  allprobs,
  trackID = NULL,
  mod = NULL,
  forecast = FALSE
)
}
\arguments{
\item{delta}{initial distribution; either
\itemize{
  \item a vector of length \code{nStates}, or
  \item a matrix of dimension \code{c(nTracks, nStates)} if \code{trackID} is provided
}}

\item{Gamma}{transition probability matrix; either
\itemize{
  \item a matrix of dimension \code{c(nStates, nStates)},
  \item an array of dimension \code{c(nStates, nStates, nTracks)} if \code{trackID} is provided, or
  \item an array of dimension \code{c(nStates, nStates, nObs)} for time-varying transition probabilities, in which case \code{\link{stateprobs_g}} is called internally
}}

\item{allprobs}{matrix of state-dependent probabilities or density values of dimension \code{c(nObs, nStates)}}

\item{trackID}{optional vector of length \code{nObs} containing \code{nTracks} unique IDs that separate tracks}

\item{mod}{optional model object containing \code{delta}, \code{Gamma}, \code{allprobs}, and
optionally \code{trackID}. When using \code{RTMB::MakeADFun} or \code{\link{qreml}} with
\code{\link{forward}} in the likelihood, these are reported automatically after model fitting
and the object returned by \code{RTMB::report()} or \code{\link{qreml}} can be passed directly.}

\item{forecast}{logical, indicating if forecast probabilities \eqn{\Pr(\text{State}_t = j \mid X_1, ..., X_t)} should be calculated instead.}
}
\value{
matrix of conditional state probabilities of dimension \code{c(nObs, nStates)}
}
\description{
Computes
\deqn{\Pr(\text{State}_t = j \mid X_1, ..., X_T)}
for a given HMM.
}
\examples{
Gamma = tpm(c(-1,-2))
delta = stationary(Gamma)
allprobs = matrix(runif(10), nrow = 10, ncol = 2)

probs = stateprobs(delta, Gamma, allprobs)
}
\seealso{
Other decoding functions: 
\code{\link{stateprobs_g}()},
\code{\link{stateprobs_p}()},
\code{\link{viterbi}()},
\code{\link{viterbi_g}()},
\code{\link{viterbi_p}()}
}
\concept{decoding functions}
