# Kalman Filter alternative derivation

Take a state space model of the form

$y_t=\alpha_t+\epsilon_t$ where $\epsilon_t\sim NID(0,\sigma_{\epsilon}^2)$

$\alpha_{t+1}=\alpha_t+\eta_t$ where $\eta\sim NID(0,\sigma_{\eta}^2)$

Futhermore, it is assumed that $E(\epsilon_t\eta_s) = 0$, for all $t,s$, that is, the error terms are independent. More, error tersma re also independent of $\alpha_1$, the initial state.

I do not get why we would apply this restrictive assumption for the Kalman Filter when we could easily estimate other parameters via MLE. For instance, suppose that $\mathbb{C}ov(\epsilon\eta) = I\sigma_{\eta,\epsilon}$ so that $E(\epsilon_t\eta_s) = 0$ for all $t\neq s$ and $E(\epsilon_t\eta_s) = \sigma_{\eta,\epsilon} \neq 0$.

We are interested in estimating $a_{t+1}=\mathbb{E}(\alpha_{t+1}|Y_t)$ and $P_{t+1}=\mathbb{V}ar(\alpha_{t+1}|Y_t)$, where $Y_{t}=(y_1,y_2,...,y_t)'$. Furthermore, I follow Durbin and Koopman textbook in that $a_{t|t}=\mathbb{E}(\alpha_{t}|Y_t)$ and $P_{t|t}=\mathbb{V}ar(\alpha_{t}|Y_t)$.

Now, $a_{t+1}=\mathbb{E}(\alpha_{t+1}|Y_t) =\mathbb{E}(\alpha_{t}+\eta_t|Y_t)=\mathbb{E}(\alpha_{t}|Y_t)=a_{t|t}$ and $P_{t+1}=\mathbb{V}ar(\alpha_{t+1}|Y_t)=\mathbb{V}ar(\alpha_{t}+\eta_t|Y_t)=\mathbb{V}ar(\alpha_{t}|Y_t) + \mathbb{V}ar(\eta_{t}|Y_t) + 2 \mathbb{C}ov(\eta_t,\alpha_t|Y_t)=P_{t|t}+\sigma_{\eta}^2+2 \mathbb{C}ov(\eta_t,\alpha_t|Y_t)$.

Under independence, $\mathbb{C}ov(\eta_t,\alpha_t)=0$. However, under my assumption, $\mathbb{C}ov(\eta_t,\alpha_{t-1}+\eta_{t-1})=\mathbb{C}ov(\eta_t,y_t-\epsilon_t)=\mathbb{C}ov(\eta_t,-\epsilon_t)=-\sigma_{\eta,\epsilon}$, leading to:

$P_{t+1}= P_{t|t}+\sigma_{\eta}^2-2\sigma_{\eta,\epsilon}$.

Now, since all distributions are normal, $P_{t+1}$ and $a_{t+1}$ are easily found if we find the expression for the pdf of $\alpha_{t}|Y_t$ - name it $f(\alpha_{t}|Y_t)$. Then,$f(\alpha_{t}|Y_t)=f(\alpha_{t}|Y_{t-1},y_t)=\frac{f(\alpha_{t},y_t|Y_{t-1})}{f(y_t|Y_{t-1})}=\frac{f(\alpha_{t}|Y_{t-1})f(y_t|Y_{t-1},\alpha_{t})}{f(y_t|Y_{t-1})}$.

Since these pdf's are fully defined by their 1st and 2nd moments, we just need to compute those as:

$\mathbb{E}(y_t|Y_{t-1})=\mathbb{E}(\alpha_t+\epsilon_t|Y_t)=a_t+0=a_t$

$\mathbb{V}ar(y_t|Y_{t-1})=\mathbb{V}ar(\alpha_t+\epsilon_t|Y_t)=\sigma_{\epsilon}+P_{t|t}$

$\mathbb{E}(y_t|Y_{t-1},\alpha_t) = \alpha_t$

$\mathbb{V}ar(y_t|Y_{t-1},\alpha_t) = \sigma_{\epsilon}$.

Substituting in the pdf's above and computing yields:

$f(\alpha_t|Y_t)=N(a_t+\frac{P_t}{P_t+\sigma_{\epsilon}^2}v_t,\frac{P_t\sigma_{\epsilon}^2}{P_t+\sigma_{\epsilon}^2})=N(a_{t|t},P_{t|t})$, where I define $v_t=y_t-a_t$, from which it follows that:

$a_{t+1}=a_{t|t}=a_t+\frac{P_t}{P_t+\sigma_{\epsilon}^2}v_t$

and

$P_{t+1}=P_{t|t}+\sigma_{\eta}^2-2\sigma_{\eta\epsilon}=\frac{P_t\sigma_{\epsilon}^2}{P_t+\sigma_{\epsilon}^2}+\sigma_{\eta}^2-2\sigma_{\eta\epsilon}$

Then, the Kalman Filter becomes,

$v_t = y_t-a_t$

$F_t = \mathbb{V}ar(v_t|Y_{t-1})=P_t+\sigma_{\epsilon}^2$

$a_{t|t}=a_t+K_t v_t$

$P_{t|t}=P_t(1-K_t)$

$a_{t+1} = a_{t|t}$

$P_{t+1} = \frac{P_t\sigma_{\epsilon}^2}{P_t+\sigma_{\epsilon}^2}+\sigma_{\eta}^2-2\sigma_{\eta\epsilon}$ for $t=1,...,n$ and $K_t = P_t/F_t$ denotes the Kalman Gain. Then $\sigma_{\eta\epsilon}$ could be estimated via MLE together with the other hyperparameters $\sigma_{\eta}$ and $\sigma_{\epsilon}$.

Does this make sense or am I missing something here? Assuming the derivation is correct, would there be any disadvantage of estimating $\sigma_{\eta\epsilon}$ via MLE?

Thanks

• If you take the trouble to write $\mathbb{V}ar$, then $\text{Var}$ or $\mathbb{V}\text{ar}$ (where "ar" is nonitalicized) would be another step ahead. – Richard Hardy Mar 11 '17 at 17:06
• I thought that would not be confusing. I will be more careful next time. – Daniel Pinto Mar 11 '17 at 17:28
• No, it is not confusing at all, it is just a matter of consistency of mathematical typing. – Richard Hardy Mar 11 '17 at 17:47

You are right in that the covariance parameter could be estimated by maximum likelihood. However, care is needed because including this additional parameter may lead to a problem of identification of the parameters.

For example, let's take the local level model defined as follows: \begin{align} &y_t = m_t + \epsilon_t \,, &\epsilon_t \sim NID(0, \sigma^2_\epsilon) \\ &m_t = \mu + m_{t-1} + \eta_t \,, &\eta_t \sim NID(0, \sigma^2_\eta) \\ &E(\epsilon_t \eta_s) = \sigma_{\epsilon\eta} &\hbox{ if } t = s \hbox{ and } 0 \hbox{ otherwise} \,. \end{align}

It can be checked that the autocovariances of this model are: \begin{align} \gamma(0) &= 2\sigma^2_\epsilon + \sigma^2_\eta + 2\sigma_{\epsilon\eta} \\ \gamma(1) &= -\sigma^2_\epsilon - \sigma_{\epsilon\eta} \\ \gamma(k) &= 0 \,, \quad \hbox{for } k > 1 \,. \end{align}

Given the sample autocovariances $\gamma(k)$, there is no unique solution to the system of equations, since we have two equations to be solved and three parameters ($\sigma^2_\epsilon$, $\sigma^2_\eta$ and $\sigma_{\epsilon\eta}$). The common restriction $\sigma_{\epsilon\eta} = 0$ can therefore be interpreted as an identifying restriction.

Morley et al. (2003)  is an interesting discussion on this issue in the field of economics. The authors fit a model consisting of a trend and a stationary cycle with and without the zero-correlation restriction between the components.

 James C. Morley, Charles R. Nelson and Eric Zivot (2003). "Why Are the Beveridge-Nelson and Unobserved-Components Decompositions of GDP so Different?". The Review of Economics and Statistics. Vol. 85, No. 2. URL http://research.economics.unsw.edu.au/jmorley/mnz03.pdf.

• Thank you javlacalle! Very useful. Other question, is the derivation of the Kalman filter above correct? – Daniel Pinto Mar 11 '17 at 20:16
• I would say that the Kalman filter does not require any modification. You could define a relatively large value for the covariance matrix of the initial state vector (instead of setting zeros outside the diagonal). Apart from this, the standard Kalman filter could be used. – javlacalle Mar 11 '17 at 21:57
• I don't get your point. As I see it, we do not need to set the covariance matrix of the initial state vector to zeros outside the diagonal. Under the assumptions of the model, they happen to be zero. But I can run a KF for this simple local level model without ever computing the non-diagonal terms. It looks just like the KF I wrote above but in the last expression for P_{t+1} the \sigma_{\eta\epsilon}^2 drops. – Daniel Pinto Mar 11 '17 at 22:33
• In other words, either we assume that the state and measurement disturbances are independent or not. If not, I argue that the expression for P_{t+1} used in the recursion (and therefore the confidence intervals around the state estimates will change). Would you then say that this is wrong? – Daniel Pinto Mar 11 '17 at 22:33
• That's what I said, instead of setting zeros, you will need to decide how to initialise the values outside the diagonal (for example, by setting a large value to them, reflecting the uncertainty in the covariance matrix). Apart from that, I would say that the standard equations of the Kalman filter would apply. – javlacalle Mar 11 '17 at 23:06