# Can I have $Q = R = I$ as covariance matrices for a kalman filter?

Assume that we have no noise in our system. We using a low pass filter to filer away some peaks in the measurements.

But our goal is just to estimate the state $$X_k$$. Can we set the $$Q_k$$ and $$R$$ to the identity matrix $$I$$? Or do we need to compute $$Q_k$$ and $$R$$?

We can assume that we have no noise from our process.

We know $$A, B, C, X_0, P_0, U_k, Y_k, H$$ but not $$Z_k, W_k$$

• Why do you have to filter out peaks if there is no noise acting on the system? Commented Mar 25, 2019 at 13:10
• @KwinvanderVeen It can be disturbance from the microcontroller. I know that $R$ can be found by $R = cov(Y_k)$ when $Y_k$ is steady state. But how about $Q$? Commented Mar 25, 2019 at 14:12
• Q is the prior variance ( or sometimes they call it the initial variance ) of the state. If you know everything else, it can be estimated using prediction error decomposition but that's a time-series methodology. ( see Andrew Harvey's blue book ) .I'm not familiar with how they would do it in control field which could be something totally different. Commented Mar 26, 2019 at 5:30
• @markleeds it's very difficult to find Q in reality for an unknow process ? Can I then set $Q=0$? Commented Mar 26, 2019 at 13:24
• Hi: I would think, even in the control field, you should give it a prior ( in bayesian framework ) or estimate it ( classical framework ). Setting it to zero says that the state has no prior variance so, no, I don't think that's the approach to take. Hopefully someone else can chime in. But check out Harvey's blue book because, if everything else is known, it's not that hard to estimate it. Commented Mar 27, 2019 at 16:59

It sounds like you have a common misconception when it comes to the Kalman filter.

If a) your process is exactly linear, b) you know the coefficients exactly, c) you know the initial state exactly, and d) you know the inputs exactly, then you have no need of a Kalman filter, because you can use the equation $$x_{k+1} = A_kx_k + B_ku_k$$ to compute the state for all $$k$$. If you know everything except the initial condition exactly, then you can just use a deterministic observer.

On the other hand, if, as is the case 99% of the time, you don't know one or more of these things exactly, then process noise is your friend.

Why?

Because process noise compensates for model/initial condition/input uncertainty and nonlinearity by telling the Kalman filter to downweight a priori estimates. This means it will rely less on the model and more on the data. Even if the data is noisy, you want to incorporate it because the model is unreliable. The beauty of the Kalman filter is that it gives you the ability to use the best of noisy data and the best of an unreliable model, so you can make a better state estimate than was possible with just one or the other.

Filter tuning is essentially a field of black magic and I've known several engineers who have made their careers doing this alone. Usually using the sensor variances and covariances is good enough for the measurement noise covariance. For the process noise covariance, I usually start out with a constant times the identity. I vary the diagonal entries until I have the right weighting between the states, and I vary the constant in front until I have the right mix of information between the model and the data going into the the estimate.

Finally, there is work on systematic filter tuning for certain applications, but it's not much help unless you're working on one of those applications.

EDIT 4/17/19:

I now realize I didn't answer the question as the questioner asked but rather what the questioner probably meant. To assist people who are actually wondering if you can put $$R = Q = I$$ for the process and measurement covariances, the answer is yes, since the identity is positive definite. However, this does NOT correspond to having no process or measurement noise, but rather to having process and measurement noise components follow a standard normal distribution. Since different components are scaled differently, this will usually not be a good tuning.

• I compute $R$ by using MATLAB command ´cov´ and then I set $Q = I$ Commented Apr 28, 2019 at 14:57
• Easy. I don't care in perfect optimized tuning. As long as it works. Commented Apr 28, 2019 at 15:04