# Math questions in Kalman filter equation derivation

I am interested in data analysis. While my working data (actually it's shopping mall's daily sale) is accumlating, I wish to find some statistical laws underlying business phenomena. I left school for more than 10 years, and I am working in a business enviroment, I have no choice but to study by myself from level 0.

I am actually learning state space method following the book of Durbin & Koopman, and I can understand basic process underlying Kalman Filter, that is, the process starts from an initial state, and then go to prediction and updating, and so on. But it is very difficult for me to understand the math derivation.

In section 4.3 of the book, the linear model is stated as:

$$y_t = Z_t\alpha_t + \varepsilon_t$$ $$\alpha_{t+1} = T_t\alpha_t + R_t\eta_t$$

with $$\varepsilon_t\sim N(0,H_t)$$ and $$\eta_t\sim N(0,Q_t)$$. Further assumption is $$\alpha_1\sim N(a_1,P_1)$$, and $$a_1$$,$$P_1$$ are known.

Let $$Y_{t-1}$$ denote ($$y_1,...y_{t-1}$$) for $$t=2,...,n$$, thus: $$v_t=y_t-E(y_t|Y_{t-1})=y_t-Z_ta_t$$ is the 1-step ahead predicted error of $$y_t$$ given $$Y_{t-1}$$. The author says that when $$Y_{t-1}$$ and $$v_t$$ are fixed then $$Y_t$$ is fixed and vice versa. Thus $$E(\alpha_t|Y_t)=E(\alpha_t|Y_{t-1},v_t)$$, and $$E(v_t|Y_{t-1})=0$$.

My questions are in the following text of that section, which are:

1. Why $$E(v_t)=0$$? Is it calculated by the law of iterated expectations? $$E(v_t)=E(E(v_t|Y_{t-1}))=E(0)=0$$
2. Why $$Cov(y_j,v_t)=E(y_jE(v_t|Y_{t-1})^\prime)$$ for $$j=1,...,t-1$$? Why the conditional mean appears in equation? As what I know, by the definition of covariance, it should be calculated straightly without using conditional mean: $$Cov(y_j,v_t) = E(y_jv_t^\prime)-E(y_j)E(v_t)^\prime = E(y_jv_t^\prime)$$

3. The updated state $$a_{t|t} = E(\alpha_t|Y_t)=E(\alpha_t|Y_{t-1},v_t)$$, and the result is shown out in the book as: $$a_{t|t} = E(\alpha_t|Y_{t-1}) + Cov(\alpha_t,v_t)[Var(v_t)]^{-1}v_t$$ How can I get this equation? I know how to calculate the conditional distribution $$X|Y$$ for a joint normally distribution $$(X,Y)$$ accorrding to Wikipedia. In my case, the conditional mean of $$\alpha_t$$ given $$Y_{t-1}$$ and $$v_t$$ is a little confused. Since there are 2 conditions: $$Y_{t-1}$$ and $$v_t$$. Consider partitioning $$Y_{t-1}$$ and $$v_t$$ into a random vector $$A = (Y_{t-1}^\prime,v_t^\prime)^\prime$$, thus my result is: $$a_{t|t} = E(\alpha_t|Y_{t-1},v_t)=E(\alpha_t) + Cov(\alpha_t,A)[Var(A)]^{-1}(A-E(A))$$ It is not the same as the equation given by the book. Sad.

1. Why $$E(v_t)=0$$? Is it calculated by the law of iterated expectations? $$E(v_t)=E(E(v_t|Y_{t−1}))=E(0)=0$$

That works, given the result that $$E(v_t|Y_{t−1}) = 0$$. Alternatively, you could do it directly:

$$E(v_t) = E( y_t - E(y_t | Y_{t-1})) = E(y_t) - E(E(y_t | Y_{t-1})) = E(y_t) - E(y_t) = 0$$

1. Why $$Cov(y_j,v_t)=E(y_j E(v_t|Y_{t−1})')$$ for $$j=1,\dots,t−1$$? Why the conditional mean appears in equation?

You're right, but Durbin and Koopman often use the Cov and Var notation implicitly with reference to a particular conditional joint distribution. For example, later on that same page they explicitly state that after they use $$Cov(\alpha_t, v_t)$$ and $$Var(v_t)$$ with reference to the joint distribution of $$\alpha_t$$ and $$v_t$$ conditional on $$Y_{t-1}$$.

1. The updated state $$a_{t|t}= E(\alpha_t|Y_t)=E(\alpha_t|Y_{t−1},v_t)$$, and the result is shown out in the book as: $$a_{t|t}=E(\alpha_t|Y_{t−1})+Cov(\alpha_t,v_t)[Var(v_t)]^{-1} v_t$$

Here, $$\alpha_t$$ and $$v_t$$ are conditionally jointly Gaussian given $$Y_{t-1}$$, so as the book notes, you can apply lemma 1 from section 4.2. To start with:

$$\begin{bmatrix} \alpha_t \\ v_t \end{bmatrix} \mid Y_{t-1} \sim N \left ( \begin{bmatrix} E(\alpha_t \mid Y_{t-1}) \\ E(v_t \mid Y_{t-1}) \end{bmatrix}, \begin{bmatrix} Var(\alpha_t) & Cov(\alpha_t, v_t) \\ Cov(\alpha_t, v_t) & Var(v_t)\\ \end{bmatrix} \right )$$

(where the note I just made about the joint conditional distribution that Cov and Var refer to still stands). Then applying the lemma is straightforward.

• In conclusion, It seems that I didn't realize the author just simplifies the notation. @cfulton Thanks to your clarification, I may catch on the author's mentality of derivation. – Wei Dec 29 '18 at 3:01
• When we focus on the process at a specific time $t$, it implicates that the series of past observations $Y_{t-1}$ is fixed, and the current output information $y_t$ is also observed. – Wei Dec 29 '18 at 3:02
• In this stage, we care about the current inner state $\alpha_t$, and also the one-step ahead prediction error $v_t$ since the current true output $y_t$ is already known. Thus we make these two variables $\alpha_t$ and $v_t$ into a joint distribution. Most important, $Y_{t-1}$ is a defaut precondition. In this case, $E(\alpha_t)$ and $E(v_t)$ truly mean to and simplify respectively $E(\alpha_t|Y_{t-1})$ and $E(v_t|Y_{t-1})$. And $E(\alpha_t|Y_{t-1},v_t)$ is just to update the value of $E(\alpha_t|Y_{t-1})$ if we assume that $E(v_t|Y_{t-1})$ is already known. Am I right? – Wei Dec 29 '18 at 3:03