Dependent on RNG, the Kalman filter may fail for the RBPF test case. You can replicate this issue by using MersenneTwister instead of StableRNG.
The filtering algorithm raises a PosDefException when evaluating the log likelihood. This is caused by non-symmetry in the innovations covariance S. A quick fix would be to deploy the following:
S = LinearAlgebra._hermitianpart!(H * Σ * H') + R
K = Σ * H' / cholesky(S)
but this problem extends to other covariance matrices. So it may be worth investigating other instances which potentially fail a Cholesky decomposition.
On a semi-related note, it is common for some models (particularly in macroeconomics) to have rank deficient covariance matrices. These will also raise errors when taking a Cholesky decomposition. While this is not necessary for the Kalman filter to run, this will fail to generate an MvNormal for the state transition density.
Dependent on RNG, the Kalman filter may fail for the RBPF test case. You can replicate this issue by using
MersenneTwisterinstead ofStableRNG.The filtering algorithm raises a
PosDefExceptionwhen evaluating the log likelihood. This is caused by non-symmetry in the innovations covarianceS. A quick fix would be to deploy the following:but this problem extends to other covariance matrices. So it may be worth investigating other instances which potentially fail a Cholesky decomposition.
On a semi-related note, it is common for some models (particularly in macroeconomics) to have rank deficient covariance matrices. These will also raise errors when taking a Cholesky decomposition. While this is not necessary for the Kalman filter to run, this will fail to generate an
MvNormalfor the state transition density.