You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lectures/additive_functionals.md
+45-53Lines changed: 45 additions & 53 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ kernelspec:
20
20
</div>
21
21
```
22
22
23
-
# Additive and Multiplicative Functionals
23
+
# Additive and multiplicative functionals
24
24
25
25
```{index} single: Models; Additive functionals
26
26
```
@@ -30,7 +30,7 @@ In addition to what's in Anaconda, this lecture will need the following librarie
30
30
```{code-cell} ipython3
31
31
:tags: [hide-output]
32
32
33
-
!pip install --upgrade quantecon
33
+
!pip install --upgrade quantecon --quiet
34
34
```
35
35
36
36
## Overview
@@ -41,9 +41,9 @@ For example, outputs, prices, and dividends typically display irregular but per
41
41
42
42
Asymptotic stationarity and ergodicity are key assumptions needed to make it possible to learn by applying statistical methods.
43
43
44
-
But there are good ways to model time series that have persistent growth that still enable statistical learning based on a law of large numbers for an asymptotically stationary and ergodic process.
44
+
But we can model time series with persistent growth while still enabling statistical learning based on a law of large numbers for an asymptotically stationary and ergodic process.
45
45
46
-
Thus, {cite}`Hansen_2012_Eca`described two classes of time series models that accommodate growth.
46
+
Thus, {cite}`Hansen_2012_Eca` described two classes of time series models that accommodate growth.
47
47
48
48
They are
49
49
@@ -65,13 +65,15 @@ We also describe and compute decompositions of additive and multiplicative proce
65
65
66
66
We describe how to construct, simulate, and interpret these components.
67
67
68
-
More details about these concepts and algorithms can be found in Hansen {cite}`Hansen_2012_Eca` and Hansen and Sargent {cite}`Hans_Sarg_book`.
68
+
More details about these concepts and algorithms can be found in Hansen {cite}`Hansen_2012_Eca` and Hansen and Sargent {cite}`Hans_Sarg_book`.
69
69
70
70
Let's start with some imports:
71
71
72
72
```{code-cell} ipython3
73
-
import numpy as np
74
-
import scipy.linalg as la
73
+
import jax.numpy as jnp
74
+
import jax.numpy as jnp
75
+
import jax.scipy.linalg as jla
76
+
from jax import jit, vmap
75
77
import quantecon as qe
76
78
import matplotlib.pyplot as plt
77
79
from scipy.stats import norm, lognorm
@@ -83,8 +85,7 @@ from scipy.stats import norm, lognorm
83
85
84
86
This lecture focuses on a subclass of these: a scalar process $\{y_t\}_{t=0}^\infty$ whose increments are driven by a Gaussian vector autoregression.
85
87
86
-
Our special additive functional displays interesting time series behavior while also being easy to construct, simulate, and analyze
87
-
by using linear state-space tools.
88
+
Our additive functional displays interesting time series behavior and is easy to construct, simulate, and analyze using linear state-space tools.
88
89
89
90
We construct our additive functional from two pieces, the first of which is a **first-order vector autoregression** (VAR)
90
91
@@ -114,7 +115,7 @@ In particular,
114
115
```{math}
115
116
:label: old2_additive_functionals
116
117
117
-
y_{t+1} - y_{t} = \nu + D x_{t} + F z_{t+1}
118
+
y_{t+1} - y_t = \nu + D x_t + F z_{t+1}
118
119
```
119
120
120
121
Here $y_0 \sim {\cal N}(\mu_{y0}, \Sigma_{y0})$ is a random
@@ -125,7 +126,7 @@ systematic but random *arithmetic growth*.
125
126
126
127
### Linear state-space representation
127
128
128
-
A convenient way to represent our additive functional is to use a [linear state space system](https://python-intro.quantecon.org/linear_models.html).
129
+
We represent our additive functional as a [linear state space system](https://python-intro.quantecon.org/linear_models.html).
129
130
130
131
To do this, we set up state and observation vectors
131
132
@@ -184,16 +185,14 @@ $$
184
185
185
186
which is a standard linear state space system.
186
187
187
-
To study it, we could map it into an instance of [LinearStateSpace](https://github.com/QuantEcon/QuantEcon.py/blob/master/quantecon/lss.py) from [QuantEcon.py](http://quantecon.org/quantecon-py).
188
-
189
-
But here we will use a different set of code for simulation, for reasons described below.
188
+
We could use [LinearStateSpace](https://github.com/QuantEcon/QuantEcon.py/blob/master/quantecon/lss.py) from [QuantEcon.py](http://quantecon.org/quantecon-py), but we will use different code for simulation, for reasons described below.
190
189
191
190
## Dynamics
192
191
193
192
Let's run some simulations to build intuition.
194
193
195
194
(addfunc_eg1)=
196
-
In doing so we'll assume that $z_{t+1}$ is scalar and that $\tilde x_t$ follows a 4th-order scalar autoregression.
195
+
We assume that $z_{t+1}$ is scalar. We also assume that $\tilde x_t$ follows a 4th-order scalar autoregression.
197
196
198
197
```{math}
199
198
:label: ftaf
@@ -211,7 +210,7 @@ $$
211
210
212
211
are strictly greater than unity in absolute value.
213
212
214
-
(Being a zero of $\phi(z)$ means that $\phi(z) = 0$)
213
+
A zero of $\phi(z)$ satisfies $\phi(z) = 0$.
215
214
216
215
Let the increment in $\{y_t\}$ obey
217
216
@@ -221,9 +220,9 @@ $$
221
220
222
221
with an initial condition for $y_0$.
223
222
224
-
While {eq}`ftaf` is not a firstorder system like {eq}`old1_additive_functionals`, we know that it can be mapped into a first order system.
223
+
While {eq}`ftaf` is not a first-order system like {eq}`old1_additive_functionals`, it can be mapped into one.
225
224
226
-
* For an example of such a mapping, see [this example](https://python.quantecon.org/linear_models.html#second-order-difference-equation).
225
+
* For an example of such a mapping, see {doc}`this example <intro:linear_models>`.
227
226
228
227
In fact, this whole model can be mapped into the additive functional system definition in {eq}`old1_additive_functionals` -- {eq}`old2_additive_functionals` by appropriate selection of the matrices $A, B, D, F$.
229
228
@@ -233,7 +232,7 @@ You can try writing these matrices down now as an exercise --- correct expressio
233
232
234
233
When simulating we embed our variables into a bigger system.
235
234
236
-
This system also constructs the components of the decompositions of $y_t$ and of $\exp(y_t)$ proposed by Hansen {cite}`Hansen_2012_Eca`.
235
+
This system also constructs the decomposition components of $y_t$ and $\exp(y_t)$ proposed by Hansen (2012).
237
236
238
237
All of these objects are computed using the code below
239
238
@@ -302,24 +301,22 @@ class AMF_LSS_VAR:
302
301
ν, H, g = self.additive_decomp()
303
302
304
303
# Auxiliary blocks with 0's and 1's to fill out the lss matrices
The class `AMF_LSS_VAR` mentioned {ref}`above <amf_lss>` does all that we want to study our additive functional.
846
841
847
-
In fact, `AMF_LSS_VAR` does more
848
-
because it allows us to study an associated multiplicative functional as well.
842
+
In fact, `AMF_LSS_VAR` does more because it allows us to study an associated multiplicative functional as well.
849
843
850
-
(A hint that it does more is the name of the class -- here AMF stands for
851
-
"additive and multiplicative functional" -- the code computes and displays objects associated with
852
-
multiplicative functionals too.)
844
+
(A hint that it does more is the name of the class -- here AMF stands for "additive and multiplicative functional" -- the code computes and displays objects associated with multiplicative functionals too.)
853
845
854
846
Let's use this code (embedded above) to explore the {ref}`example process described above <addfunc_eg1>`.
855
847
@@ -1100,9 +1092,9 @@ The heavy lifting is done inside the `AMF_LSS_VAR` class.
1100
1092
The following code adds some simple functions that make it straightforward to generate sample paths from an instance of `AMF_LSS_VAR`.
0 commit comments