This is an old version, view current version.

26.1 Stan functions

real hmm_marginal(matrix log_omega, matrix Gamma, vector rho)
Returns the log probability density of y, with xn 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ωkn=logp(ynxn=k,ϕ), log density of each output,

  • Gamma: Γij=p(xn=j|xn1=i,ϕ), the transition matrix,

  • rho: ρk=p(x0=kϕ), 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ϕ,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×N matrix. The ith column is a simplex of probabilities for the nth variable. Moreover, let A be the output. Then Aij=p(xj=iϕ,y). This function may only be used in transformed data and generated quantities.