# How to find optimal noise covariance matrices Q & R

I am trying to use the discrete Kalman filter for forecasting and I wonder what is commonly considered as the optimal way of determining the measurement noise covariance constants (Q and R) for a given time series? Do you recommend some approaches based on your research/experience?

Essentially, there are 3 ways to estimate Q & R.

1. approximate
• calculate variate estimate of error in a controlled environment
• if z doesn't change, calculate variance estimate of z
• if z does change, calculate variance of regression estimate of z
2. guess
• use some constant multiplied by the identity matrix
• higher the constant, higher the noise
3. MLE
• pykalman's em
• unfortunately, non-convex problem => local optima

Check out the rest of my post here