# How to infer a missing observation in a state space model?

I read here that "structural time series models handle missing values naturally, following the rules of conditional probability. Posterior inference can be used to impute missing values, with uncertainties." So I'm trying to figure out how one would do this in a state space model. Let's say we have observations y_t and latent states z_t with some observation and transition equations so that the graphical model looks like this:

y1     y2     y3
^      ^      ^
|      |      |
z1 --> z2 --> z3


Let's say y2 is missing but y1 and y3 are known. How would we write the conditional distribution of y2 given all the other observations?

I tried using Bayes Theorem (and Z as the vector) to get

p(y2|y1, y3, Z) = p(y1, y3, Z|y2) * p(y2)


disregarding normalization. We can assume some relevant prior for the data, so p(y2) isn't a problem, but I don't know how that likelihood would be evaluated.

There is a vast literature about this topic. The model schematic you have drawn shows a hidden markov model. This class of model assumes that $$p(y_t)$$ is independent of all other variables given $$z_t$$ i.e.
$$p(y_2| y_1, y_3) = \sum_{z2} \ p(y_2|z_2) \ p(z_2|y_1,y_3)$$
Therefore, what you are really asking about is how to estimate $$p(z_2|y_{1:T})$$. What you are then asking about is how filtering and smoothing work. Filtering, generally is finding $$p(z_t | y_{1:t-1})$$ and smoothing is finding $$p(z_t | y_{1:T})$$. There are many resources about this online but here is a freely available and excellent on the topic book.You may also find section 2 of this tutorial helpful and a more concise treatment of this topic.
• I think you made a small mistake: $p(y_2|y_1,y_3,z_{1:3})$ is simply equal to $p(y_2|z_2)$ because of conditional independence given $z_2$. I think you meant $p(y_2|y_1,y_3)$ because $z_{1:3}$ are not observable, and then you have $p(y_2|y_1, y_3) = p(y_2|z_2)p(z_2|y_1,y_3)$. Commented Jul 9, 2019 at 21:10
• Actually, I fear I made a mistake as well. In the above derivation, you still need to marginalize out $z_2$. So $p(y_2|y_1,y_3) = \sum_{z_2} p(y_2, z_2|y_1,y_3) = \sum_{z_2} p(y_2|y_1,y_3,z_2)p(z_2|y_1,y_3) = \sum_{z_2} p(y_2|z_2)p(z_2|y_1,y_3)$ where you replace the sums with integrals if $z_2$ is a continuous random variable. The final equality holds because of conditional independence of $y_2$ given $z_2$. Commented Jul 10, 2019 at 7:11