I have a live signal that needs filtering, and I'm trying to compare a Kalman filter with a simple exponential filter. For this I generated an artificial ground truth signal, add some noise and filter it with both methods.
The problem is that, while the result from the Kalman filter 'looks' better, I can't quantify how much better it is because its output lags behind the signal. When I simply compute the error between a noisy sample and a filtered sample at time T, the difference is always higher than between the noisy sample and the ground truth sample at the same time.
Is there a way of correctly computing the error in these cases? I thought about computing a least squares fit between the filtered and ground truth signals, but that feels like 'cheating' a bit, as it looks at the best possible case and also doesn't account for the filter lag.
I've plotted the outputs up to t=140. Both the exponential filter (red) and kalman filter (green) are lagging behind the current noisy sample (blue). If I try to compute the squared error by comparing the ground truth value at t=140 with kalman or exponential values at t=140, the error will be large, and at times even larger than the error between the ground truth and the noisy signal (second picture top).
This makes the exponential filter look better, just because it has less lag than the kalman filter. If I try to account for lag, i.e. compute the error between the kalman filter at t=140 and ground truth at the closest t ~ 137-ish, then the squared error graphs look better (second picture bottom), but I'm not sure if this is the correct thing to do.
Edit 2 I now realize that these are not really time series, but rather processed as a 2D signal. So 't=' should really be 'x=', with the value being y. This explains why the sequences are not synchronized in time. But I think the question is still valid.