# Particle filter and measurement equation

Hi, I would like to ask about what is the correct way to write the state space equation when using particle filter.

To illustrate better, suppose the non linear case, as used in the simulation with stochastic volatility by Born and Pfeifer in https://github.com/JohannesPfeifer/Particle_Filtering
y_t=\phi y_{t-1}+\sigma_t e_t
\log \sigma_t=\log \sigma_{t-1}+ u_t
where the first equation is a measurement and the second is the state transition equation.
In my case, I have missing observation, so I expect filter and smoother to fill the gaps. For that reason, I put the level variable into another state transition equation, s.t.
a_t=\phi a_{t-1}+\sigma_t e_t
\log \sigma_t=\log \sigma_{t-1}+ u_t
and my measurement becomes y_t=a_t.

However, here I get lost. To my understanding, the particle filter requires measurement error, so that particles would not become degenerate. I was wondering how dynare handles this situation? [I am not sure, but can the answer be related to this [post](Question about particle filter code)]

Does that mean I have to rewrite the specification differently? As an alternative, I was thinking to write in the following way:
Measurement: y_t=\phi a_{t-1}+\sigma_t v_t.
State equations
a_t=\phi a_{t-1}+\sigma_t e_t
\log \sigma_t=\log \sigma_{t-1}+ u_t

But I guess this fails one of the assumptions, such that errors in state and measurement equations are independent?

@frederic.karame Do you know the answer?

If my understanding is correct, there is no need to rewrite the model. Think in the Kalman filter update equation:
\alpha_{t|t} = \alpha_{t|t-1} + K_t \eta_t
The last term updates the state prediction \alpha_{t|t-1} to obtain the filtered state \alpha_{t|t}.
If no observation is available, there is no update so \alpha_{t|t} = \alpha_{t|t-1} in this case.
This is the same for a particle filter with particle swarms.

Thanks for the answer. Yes, that is how it would work with the missing data in Kalman filter. But where I am still confused is that the predictive density p(y|a) is degenerate as y_t=a_t, meaning that if one particle does not hit this point, weights will be equal to zero.

If I understand you correctly, you are observing one of the state variables.

Exactly, I specify the model as if I observe some state variables. This is entirely to fill missing gaps using the law of motion of the state equation even though this leads to a much larger state vector.

Given that, Kalman filter can handle this easily but I am just unsure if particle filter can. Since the measurement does not have any measurement errors, particles that do not satisfy this constraint will have a density of zero, leading to degeneracy. I think engineering people face the same issue if their measurements, provided by some sensors, are too precise such that particles do not hit the peak of density. My case is even more extreme, such that the measurement is exact.

Again, I would like to thank a lot for looking into this.