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(yn∣xn=k,ϕ), log density of each output,Gamma
: Γij=p(xn=j|xn−1=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 nth 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.