# Latent State and Parameter Learning in Kalman Filter

I want to estimate the latent factor, evolution matrix and the observation matrix of a linear Kalman filter in a Gibbs sampling Framework.

However, when I test my model on simulated data, the median of the posterior distribution fails to collapse to the "true" value.

The kalman filter takes the following form

$Y_t = HX_t + \epsilon_y$

$X_t = \beta X_{t-1} + \epsilon_x$

Where $X_t$ is a scalar and $Y_t$ is a $n*1$ vector. $\epsilon_y$ are assumed to be multivariate normal and $\epsilon_x$ is normal.

The prior is the simplest conjugate form possible.

$\epsilon_x \sim N(0, \sigma_x^2)$, $\sigma_x^2$ distributed Inverse Gamma.

$\epsilon_y \sim N(0, I\sigma_y^2)$, $\sigma_y^2$ distributed Inverse Gamma.

$\beta \sim N(b, B\sigma_x^2)$

$H \sim N(b_H,B_H\sigma_y^2)$

Here is my Gibbs scheme

(a)Draw $X^*$ conditioning on all the parameters by forward filtering back ward smoothing (FFBS).

(b) Update the posterior of the $\epsilon _x, \epsilon _y$ and draw new observations

(c) Update the posterior of the $H, \beta$ and draw new observations

For programming side, I unit test the FFBS algorithm and I implement the same Bayesian setup with the particle learning filter and it works OK.

Therefore, I wonder if there is anything wrong with my overall scheme or it is just too greedy to estimate everything from thin air in the kalman filter setting.