% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/decoding_functions.R
\name{stateprobs_g}
\alias{stateprobs_g}
\title{Calculate conditional local state probabilities for inhomogeneous HMMs}
\usage{
stateprobs_g(
  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}{array of transition probability matrices of dimension \code{c(nStates, nStates, nObs)},
where the first slice of each track is ignored as there is no transition into the start of a track.
For a single track, an array of dimension \code{c(nStates, nStates, nObs-1)} is also accepted.}

\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_g}} 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-1})} 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 inhomogeneous HMMs
}
\examples{
Gamma = tpm_g(runif(10), matrix(c(-1,-1,1,-2), nrow = 2, byrow = TRUE))
delta = c(0.5, 0.5)
allprobs = matrix(runif(20), nrow = 10, ncol = 2)

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