Estimating a dynamic switching process

My understanding of your definition is that there are two independent noises, \epsilon_1 and \epsilon_2, and the R_t matrix determines which one feeds the system (depending on whether \varphi is 0 or 1). But whichever noise is active, it should feed the second state, \eta_t not the a_t. So shouldn’t R_t be:

\begin{bmatrix} 0 & 0 \\ \varphi_t & (1-\varphi_t) \end{bmatrix} \begin{bmatrix} \epsilon_{t,1} \\ \epsilon_{t,2} \end{bmatrix}

which produces

\begin{bmatrix} 0 \\ \varphi_t \epsilon_{t,1} + (1-\varphi_t) \epsilon_{t,2} \end{bmatrix}

Thus

\eta_t = \eta_{t-1} + \omega_t = \eta_{t-1} + \varphi_t \epsilon_{t,1} + (1-\varphi_t) \epsilon_{t,2}

Anyway, I might be wrong, it’s not important to the question.

The HMM would have the following transition matrix

\Pi_{i,j} = \begin{bmatrix} 1-p & p\\ 1-p & p \end{bmatrix}

where p is the shock probability, e.g. p=0.01 (I labelled it epsilon in the question).

At the moment I’m having problems running the HMM example linked above. I’m getting errors but trying to figure them out…