How can I debug and check the consistency of a Kalman filter? I understand the basic principles involved in Kalman filtering and I have spent some time implementing several algorithms in MATLAB. The problem I'm facing now is to check if the algorithm and my code actually do the right thing.
I know that there are statistical tests, such as the normalized estimation error squared (NEES) test and the normalized innovation squared (NIS) test. Their principle is described in the literature, but the description of implementation and interpretation of the results are pretty vague. In the simulations I currently do, I can't get the NEES test to pass even for the perfectly matched model (while the NIS test normally passes)!
So my question is: Does anyone have tips, tricks, hints or references on how to check the consistency of the filter and debug the code if needed (especially regarding the interpretation of test outcomes)?
(Remark: I first posted this on signal processing but figured it might receive more attention here. If more detailed information is needed, I'm happy to make my post more specific!)
 A: *

*Generate your own measurements, in a known scenario, that fulfills the assumptions

*Test it in the known scenario. If you do it in 1 or 2 dimensions, you can even do it by hand.

*Look at the properties. The autocorrelation of the innovation must be white if I am not mistaken (in a linear scenario, not 100% sure, but I know that in non-linear scenarios it is not. If some), so if you take the autocorrelation it should look approximately like a delta function.

*There are implementations online, it won't tell you that yours is right but it can make you think about the differences if there are.

*Check if what you get is what you are expecting to get. What is this? Well, in 2D, you are expecting to get an estimation which balances the prediction and the measurement, right? So If the result is not sort of in the middle, it is probably wrong.

*Be suspicious about everything you can. 


And then if you have any particular point where you are not sure, post it.
There is a very nice description here, at least I liked it very much.
https://cs.adelaide.edu.au/~ianr/Teaching/Estimation/LectureNotes2.pdf
And since the link can break at any point, it is the file
Estimation II from Ian Reid, Hillary Term 2001
