# How critical is the estimation of the covariance matrices in Kalman-Filter

Considering the follow basic Kalman Filter, following the Wikipedia convention

$$$$\begin{split} x_k &= F_kx_{k-1} + B_k u_k +w_k\\ y_k &= H_kx_k + v_k \end{split}$$$$

Where $$w_k \sim \mathcal{N}(0, Q)$$, $$v_k \sim \mathcal{N}(0, R)$$. My understanding is that we have to estimate the covariance matrix $$R,Q$$ ahead of time.

My question is how importance does the estimation needs to be. If my estimation is off, how badly does it affect my Kalman Filter in general? Because in real life the estimation of such covariance matrices might be tricky.. Since the whole point of using Kalman Filter is acknowledging that measurement is different from real state, so it's hard to get real $$R,Q$$ no matter how we measure it.:)

Or let's be a little bit quantitative, if instead of using true $$R,Q$$, I use $$R' = \alpha R$$, $$Q' = \alpha Q$$ in my Kalman Filter, how badly does it affect my filter, comparing to using true $$R,Q$$, when $$\alpha >> 1$$ vs when $$\alpha << 1$$? And this example is when I estimate the "variance" part incorrectly. What if I estimate the correlation part incorrectly?

This is just an example, my real question is if my estimation of $$R,Q$$ is off, how badly does it affect my Kalman Filter in general?

Assuming that your model of the dynamics is correct (i.e. $$F_k$$, $$B_k$$ and $$H_k$$) then the good news is that any (positive semi-definite) choice for $$Q$$ and $$R$$ will result in a state estimator that is stable, so the estimated state converges to the true state in the absence of disturbances $$w_k$$ and $$v_k$$ and converge to some bound around the true state when there are disturbances.

If the covariance matrices are off by some scalar factor $$\alpha$$, then one still yields the same state estimate. This can be seen by looking at the matrix update equations from the Kalman filter

\begin{aligned} \mathbf {P} _{k\mid k-1}&=\mathbf {F} _{k}\mathbf {P} _{k-1\mid k-1}\mathbf {F} _{k}^{\textsf {T}}+\mathbf {Q} _{k},\\ \mathbf {S} _{k}&=\mathbf {H} _{k}\mathbf {P} _{k\mid k-1}\mathbf {H} _{k}^{\textsf {T}}+\mathbf {R} _{k},\\ \mathbf {K} _{k}&=\mathbf {P} _{k\mid k-1}\mathbf {H} _{k}^{\textsf {T}}\mathbf {S} _{k}^{-1},\\ \mathbf {P} _{k|k}&=\left(\mathbf {I} -\mathbf {K} _{k}\mathbf {H} _{k}\right)\mathbf {P} _{k|k-1}. \end{aligned}

Namely, instead of $$\mathbf {P} _{k|i}$$, $$\mathbf {Q} _{k}$$ and $$\mathbf {R} _{k}$$ using $$\mathbf {P'} _{k|i}=\alpha\mathbf {P} _{k|i}$$, $$\mathbf {Q'} _{k}=\alpha\mathbf {Q} _{k}$$ and $$\mathbf {R'} _{k}=\alpha\mathbf {R} _{k}$$ respectively yields

\begin{aligned} \mathbf {P'} _{k\mid k-1}&=\mathbf {F} _{k}\mathbf {P'} _{k-1\mid k-1}\mathbf {F} _{k}^{\textsf {T}}+\mathbf {Q'} _{k} = \alpha\left(\mathbf {F} _{k}\mathbf {P} _{k-1\mid k-1}\mathbf {F} _{k}^{\textsf {T}}+\mathbf {Q} _{k}\right),\\ \mathbf {S'} _{k}&=\mathbf {H} _{k}\mathbf {P'} _{k\mid k-1}\mathbf {H} _{k}^{\textsf {T}}+\mathbf {R'} _{k} = \alpha\left(\mathbf {H} _{k}\mathbf {P} _{k\mid k-1}\mathbf {H} _{k}^{\textsf {T}}+\mathbf {R} _{k}\right),\\ \mathbf {K'} _{k}&=\mathbf {P'} _{k\mid k-1}\mathbf {H} _{k}^{\textsf {T}}\mathbf {S'} _{k}^{-1} = \frac\alpha\alpha\mathbf {P} _{k\mid k-1}\mathbf {H} _{k}^{\textsf {T}}\mathbf {S} _{k}^{-1} = \mathbf {K} _{k},\\ \mathbf {P'} _{k|k}&=\left(\mathbf {I} -\mathbf {K'} _{k}\mathbf {H} _{k}\right)\mathbf {P'} _{k|k-1} = \alpha\left(\mathbf {I} -\mathbf {K} _{k}\mathbf {H} _{k}\right)\mathbf {P} _{k|k-1}. \end{aligned}

So the gain matrix $$\mathbf {K'} _{k}$$ remains the same under any scalar factor $$\alpha$$, so the state update step will also remain the same. One might run into some numerical issues when $$\alpha$$ is really big or really small, but on the other side $$\alpha$$ can also be used for normalization and make the Kalman filter more numerically robust. Such normalization will also change the direct relationship between $$\mathbf {P'} _{k|k}$$ and the uncertainty of the state estimate, so keep the factor $$\alpha$$ in mind when interpreting $$\mathbf {P'} _{k|k}$$.

I can not answer your more general question of the exact impact of using covariance matrices that deviate is more ways that just a scalar factor. It can be noted that chosing the $$Q$$ and $$R$$ matrices is often also considered a tuning step of making a Kalman filter. These matrices can also be used to reduce the impact of other types of disturbances (so other than zero mean Gaussian white noise).

• Can you elaborate why "any (positive semi-definite) choice for Q and R will result in a state estimator that is stable". Or is there a reference you can point me to? Commented May 25 at 20:08
• @MattFrank this is similar to how LQR results in a stabilizing state feedback gain for any positive definite matrices (LQR and Kalman filter are the dual of each other). There are some remarks, since in my answer I state positive semi-definite and not positive definite. When R or Q are only positive semi-definite and not positive definite then there are some edge cases. More details about the stability of Kalman filters can be found in chapter 7 of A. H. Jazwinski, Stochastic Processes and Filtering Theory. New York: Academic, 1972. Commented May 26 at 9:10
• Thank you. to avoid back and forth in the comment section, I asked a new question here: math.stackexchange.com/questions/4923024/… If you can kindly take a look that'd be great. Commented May 27 at 1:38