26.1 Stan functions
real hmm_marginal(matrix log_omega, matrix Gamma, vector rho)
Returns the log probability density of \(y\), with \(x_n\) integrated out at each iteration.
The arguments represent (1) the log density of each output, (2) the transition matrix, and (3) the initial state vector.
log_omega: \(\log \omega_{kn} = \log p(y_n \mid x_n = k, \phi)\), log density of each output,Gamma: \(\Gamma_{ij} = p(x_n = j | x_{n - 1} = i, \phi)\), the transition matrix,rho: \(\rho_k = p(x_0 = k \mid \phi)\), the initial state probability.
int[] hmm_latent_rng(matrix log_omega, matrix Gamma, vector rho)
Returns a length \(N\) array of integers over \(\{1, ..., K\}\),
sampled from the joint posterior distribution of the hidden states,
\(p(x \mid \phi, y)\).
May be only used in transformed data and generated quantities.
matrix hmm_hidden_state_prob(matrix log_omega, matrix Gamma, vector rho)
Returns the matrix of marginal posterior probabilities of each hidden state value. This will be a \(K \times N\) matrix.
The \(n^\mathrm{th}\) column is a simplex of probabilities for the \(n^\mathrm{th}\) variable.
Moreover, let \(A\) be the output. Then
\(A_{ij} = p(x_j = i \mid \phi, y)\).
This function may only be used in transformed data and generated quantities.