@@ -522,13 +522,13 @@ The latter represents a linear state space model of the form
522522523523$$
524524\begin{aligned}
525- x_{t+1} & = A x_t + C w_{t+1}
525+ X_{t+1} & = A X_t + C w_{t+1}
526526 \\
527- y_t & = G x_t + H v_t
527+ Y_t & = G X_t + H v_t
528528\end{aligned}
529529$$
530530531-where the shocks $w_t$ and $v_t$ are IID standard normals.
531+where $X_t$ and $Y_t$ denote random variables, and the shocks $w_t$ and $v_t$ are IID standard normals.
532532533533To connect this with the notation of this lecture we set
534534@@ -557,13 +557,13 @@ on {cite}`Ljungqvist2012`, section 2.9.2.
557557Suppose that
558558559559* all variables are scalars
560-* the hidden state $\{x_t\}$ is in fact constant, equal to some $\theta \in \mathbb{R}$ unknown to the modeler
560+* the hidden state $\{X_t\}$ is in fact constant, equal to some $\theta \in \mathbb{R}$ unknown to the modeler
561561562-State dynamics are therefore given by {eq}`kl_xdynam` with $A=1$, $Q=0$ and $x_0 = \theta$.
562+State dynamics are therefore given by {eq}`kl_xdynam` with $A=1$, $Q=0$ and $X_0 = \theta$.
563563564-The measurement equation is $y_t = \theta + v_t$ where $v_t$ is $N(0,1)$ and IID.
564+The measurement equation is $Y_t = \theta + v_t$ where $v_t$ is $N(0,1)$ and IID.
565565566-The task of this exercise to simulate the model and, using the code from `kalman.py`, plot the first five predictive densities $p_t(x) = N(\mu_t, \Sigma_t)$.
566+The task of this exercise is to simulate the model and, using the code from `kalman.py`, plot the first five predictive densities $p_t(x) = N(\mu_t, \Sigma_t)$ for $X_t$.
567567568568As shown in {cite}`Ljungqvist2012`, sections 2.9.1--2.9.2, these distributions asymptotically put all mass on the unknown value $\theta$.
569569@@ -585,7 +585,7 @@ Your figure should -- modulo randomness -- look something like this
585585586586```{code-cell} ipython3
587587# Parameters
588-θ = 10 # Constant value of state x_t
588+θ = 10 # Constant value of state X_t
589589A, C, G, H = 1, 0, 1, 1
590590ss = LinearStateSpace(A, C, G, H, mu_0=θ)
591591@@ -645,7 +645,7 @@ Plot $z_t$ against $t$, setting $\epsilon = 0.1$ and $T = 600$.
645645646646```{code-cell} ipython3
647647ϵ = 0.1
648-θ = 10 # Constant value of state x_t
648+θ = 10 # Constant value of state X_t
649649A, C, G, H = 1, 0, 1, 1
650650ss = LinearStateSpace(A, C, G, H, mu_0=θ)
651651@@ -682,25 +682,27 @@ plt.show()
682682:label: kalman_ex3
683683```
684684685-As discussed {ref}`above <kalman_convergence>`, if the shock sequence $\{W_t\}$ is not degenerate, then it is not in general possible to predict $x_t$ without error at time $t-1$ (and this would be the case even if we could observe $x_{t-1}$).
685+As discussed {ref}`above <kalman_convergence>`, if the shock sequence $\{W_t\}$ is not degenerate, then it is not in general possible to predict $X_t$ without error at time $t-1$ (and this would be the case even if we could observe $X_{t-1}$).
686686687687Let's now compare the prediction $\mu_t$ made by the Kalman filter
688-against a competitor who **is** allowed to observe $x_{t-1}$.
688+against a competitor who **is** allowed to observe $X_{t-1}$.
689689690-This competitor will use the conditional expectation $\mathbb E[ x_t
691-\,|\, x_{t-1}]$, which in this case is $A x_{t-1}$.
690+This competitor will use the conditional expectation $\mathbb E[ X_t
691+\,|\, X_{t-1}]$, which in this case is $A X_{t-1}$.
692692693693The conditional expectation is known to be the optimal prediction method in terms of minimizing mean squared error.
694694695-(More precisely, the minimizer of $\mathbb E \, \| x_t - g(x_{t-1}) \|^2$ with respect to $g$ is $g^*(x_{t-1}) := \mathbb E[ x_t \,|\, x_{t-1}]$)
695+(More precisely, the minimizer of $\mathbb E \, \| X_t - g(X_{t-1}) \|^2$ with respect to $g$ is $g^*(X_{t-1}) := \mathbb E[ X_t \,|\, X_{t-1}]$)
696696697697Thus we are comparing the Kalman filter against a competitor who has more
698698information (in the sense of being able to observe the latent state) and
699699behaves optimally in terms of minimizing squared error.
700700701-Our horse race will be assessed in terms of squared error.
701+Our horse race will be assessed in terms of realized squared error.
702702703-In particular, your task is to generate a graph plotting observations of both $\| x_t - A x_{t-1} \|^2$ and $\| x_t - \mu_t \|^2$ against $t$ for $t = 1, \ldots, 49$.
703+In particular, your task is to generate a graph plotting simulated realizations of both $\| X_t - A X_{t-1} \|^2$ and $\| X_t - \mu_t \|^2$ against $t$ for $t = 1, \ldots, 49$.
704+705+In the code below, `x[:, t]` is the realized value of $X_t$ along the simulated path.
704706705707For the parameters, set $G = I, R = 0.5 I$ and $Q = 0.3 I$, where $I$ is
706708the $2 \times 2$ identity.
@@ -731,7 +733,7 @@ $$
731733732734and $\mu_0 = (8, 8)$.
733735734-Finally, set $x_0 = (0, 0)$.
736+Finally, set the realized initial state to $x_0 = (0, 0)$.
735737736738737739```{exercise-end}
@@ -806,5 +808,5 @@ Try varying the coefficient $0.3$ in $Q = 0.3 I$ up and down.
806808807809Observe how the diagonal values in the stationary solution $\Sigma$ (see {eq}`kalman_dare`) increase and decrease in line with this coefficient.
808810809-The interpretation is that more randomness in the law of motion for $x_t$ causes more (permanent) uncertainty in prediction.
811+The interpretation is that more randomness in the law of motion for $X_t$ causes more (permanent) uncertainty in prediction.
810812```