I’m trying to estimate parameters (function coefficients, as well as noise variances) of a dynamical system, and the expression for state vector and its covariance are given by the Kalman filter. As is, the program yields very high divergence rate ~93%, and the estimation results are not sensible.
I’m not exactly sure what the underlying cause is, though I have a few guesses. If it’s numerical instability on the estimated state covariance matrix, I can try and use square-root filter, albeit it’s a lot more complicated and may easily introduce sneaky bugs. If the instability comes from matrix operations in computing K, then I can try and implement it manually using more efficient methods.
HLW_lewis.stan (3.2 KB)