Skip to content

Commit 7c6396a

Browse files
authored
[kalman_filter_var, lq_consumption_smoothing, robust_permanent_income] Align with QuantEcon style guide #944
1 parent 94222f2 commit 7c6396a

5 files changed

Lines changed: 587 additions & 658 deletions

File tree

‎lectures/kalman.md‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ It is aimed at readers who either
4646
* have heard of the Kalman filter but don't know how it works, or
4747
* know the Kalman filter equations, but don't know where they come from
4848

49+
Subsequent lectures use the same recursive logic in more applied and more econometric settings.
50+
51+
See {doc}`kalman_2` for an economic application in which a firm infers a worker's hidden human capital and effort.
52+
53+
See {doc}`kalman_filter_var` for a derivation of the innovations representation and its connection to vector autoregressions.
54+
4955
For additional (more advanced) reading on the Kalman filter, see
5056

5157
* {cite}`Ljungqvist2012`, section 2.7
@@ -258,7 +264,9 @@ and
258264
```
259265

260266
```{note}
261-
A proof can be found in {cite}`Bishop2006`. To get from his expressions to the ones used above, you will also need to apply the [Woodbury matrix identity](https://en.wikipedia.org/wiki/Woodbury_matrix_identity).
267+
A proof can be found in {cite}`Bishop2006`.
268+
269+
To get from his expressions to the ones used above, you will also need to apply the [Woodbury matrix identity](https://en.wikipedia.org/wiki/Woodbury_matrix_identity).
262270
```
263271

264272
Here $\Sigma G^\top (G \Sigma G^\top + R)^{-1}$ is the matrix of population
@@ -457,7 +465,9 @@ Repeating {eq}`kl_mlom0`, the dynamics for $\mu_t$ and $\Sigma_t$ are as follows
457465
These are the standard dynamic equations for the Kalman filter (see, for example, {cite}`Ljungqvist2012`, page 58).
458466

459467
```{note}
460-
Here $\mu_t$ is the filter's prediction of the hidden state $X_t$. In much of the Kalman filter literature it is written $\hat x_t$, emphasizing that it is an estimate of $X_t$.
468+
Here $\mu_t$ is the filter's prediction of the hidden state $X_t$.
469+
470+
In much of the Kalman filter literature it is written $\hat x_t$, emphasizing that it is an estimate of $X_t$.
461471
```
462472

463473
(kalman_convergence)=
@@ -501,7 +511,9 @@ Equation {eq}`kalman_dare` is known as a [discrete-time algebraic Riccati equati
501511

502512
Conditions under which a fixed point exists and the sequence $\{\Sigma_t\}$ converges to it are discussed in {cite}`AHMS1996` and {cite}`AndersonMoore2005`, chapter 4.
503513

504-
A sufficient (but not necessary) condition is that all the eigenvalues $\lambda_i$ of $A$ satisfy $|\lambda_i| < 1$ (cf. e.g., {cite}`AndersonMoore2005`, p. 77).
514+
A sufficient (but not necessary) condition is that all the eigenvalues $\lambda_i$ of $A$ satisfy $|\lambda_i| < 1$.
515+
516+
See, for example, {cite}`AndersonMoore2005`, p. 77.
505517

506518
(This strong condition assures that the unconditional distribution of $X_t$ converges as $t \to \infty$.)
507519

@@ -583,6 +595,8 @@ Your figure should -- modulo randomness -- look something like this
583595
:class: dropdown
584596
```
585597

598+
Here is one solution:
599+
586600
```{code-cell} ipython3
587601
# Parameters
588602
θ = 10 # Constant value of state X_t
@@ -643,6 +657,8 @@ Plot $z_t$ against $t$, setting $\epsilon = 0.1$ and $T = 600$.
643657
:class: dropdown
644658
```
645659

660+
Here is one solution:
661+
646662
```{code-cell} ipython3
647663
ϵ = 0.1
648664
θ = 10 # Constant value of state X_t
@@ -743,6 +759,8 @@ Finally, set the realized initial state to $x_0 = (0, 0)$.
743759
:class: dropdown
744760
```
745761

762+
Here is one solution:
763+
746764
```{code-cell} ipython3
747765
# Define A, C, G, H
748766
G = np.identity(2)

‎lectures/kalman_2.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,14 @@ In this lecture, we'll use the Kalman filter to
3636
infer a worker's human capital and the effort that the worker devotes to accumulating
3737
human capital, neither of which the firm observes directly.
3838

39+
This lecture is an application of the filtering and forecasting recursion introduced in {doc}`kalman`.
40+
3941
The firm learns about those things only by observing a history of the output that the worker generates for the firm, and from understanding how that output depends on the worker's human capital and how human capital evolves as a function of the worker's effort.
4042

4143
We'll posit a rule that expresses how much the firm pays the worker each period as a function of the firm's information each period.
4244

45+
The lecture {doc}`kalman_filter_var` uses the same recursion to construct innovations, likelihoods, and vector autoregressions.
46+
4347
In addition to what's in Anaconda, this lecture will need the following libraries:
4448

4549
```{code-cell} ipython3

0 commit comments

Comments
 (0)