Skip to content

Commit 44637a1

Browse files
Tom's July 28 edits of a quantecon lecture
1 parent a357090 commit 44637a1

File tree

1 file changed

+63
-4
lines changed

1 file changed

+63
-4
lines changed

lectures/time_series_with_matrices.md

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ QuantEcon lecture.
4040

4141
(That lecture also describes some technicalities about second-order linear difference equations.)
4242

43+
In this lecture, we'll also learn about an **autoregressive** representation and a **moving average** representation of a non-stationary
44+
univariate time series $\{y_t\}_{t=0}^T$.
45+
4346
We'll also study a "perfect foresight" model of stock prices that involves solving
4447
a "forward-looking" linear difference equation.
4548

@@ -119,7 +122,7 @@ $$
119122
where
120123

121124
$$
122-
y = \begin{bmatrix} y_1 \cr y_2 \cr \cdots \cr y_T \end{bmatrix}
125+
y = \begin{bmatrix} y_1 \cr y_2 \cr \vdots \cr y_T \end{bmatrix}
123126
$$
124127

125128
Evidently $y$ can be computed from
@@ -284,13 +287,13 @@ governed by the system
284287

285288
$$
286289
A y = b + u
287-
$$
290+
$$ (eq:eqar)
288291
289292
The solution for $y$ becomes
290293
291294
$$
292295
y = A^{-1} \left(b + u\right)
293-
$$
296+
$$ (eq:eqma)
294297
295298
Let’s try it out in Python.
296299
@@ -350,6 +353,7 @@ plt.show()
350353
```
351354
352355
356+
353357
## Computing Population Moments
354358
355359
@@ -449,6 +453,7 @@ my_process = population_moments(
449453
alpha0=10.0, alpha1=1.53, alpha2=-.9, T=80, y_1=28., y0=24., sigma_u=1)
450454
451455
mu_y, Sigma_y = my_process.get_moments()
456+
A_inv = my_process.A_inv
452457
```
453458
454459
It is enlightening to study the $\mu_y, \Sigma_y$'s implied by various parameter values.
@@ -509,7 +514,6 @@ But just to set the stage for that analysis, let's increase $T$ to 100 and print
509514
510515
```{code-cell} ipython3
511516
my_process = population_moments(alpha0=0, alpha1=.8, alpha2=0, T=100, y_1=0., y0=0., sigma_u=1)
512-
513517
mu_y, Sigma_y = my_process.get_moments()
514518
print("bottom right corner of Sigma_y = \n", Sigma_y[95:,95:])
515519
```
@@ -525,6 +529,61 @@ There is a lot to be learned about the process by staring at the off diagonal el
525529
+++
526530
527531
532+
## Moving Average Representation
533+
534+
Let's print out $A^{-1}$ and stare at its structure
535+
536+
* is it triangular or almost triangular or $\ldots$ ?
537+
538+
To study the structure of $A^{-1}$, we shall print just up to $3$ decimals.
539+
540+
Let's begin by printing out just the upper left hand corner of $A^{-1}$
541+
542+
```{code-cell} ipython3
543+
with np.printoptions(precision=3, suppress=True):
544+
print(A_inv[0:7,0:7])
545+
```
546+
547+
548+
549+
550+
Evidently, $A^{-1}$ is a lower triangular matrix.
551+
552+
553+
Let's print out the lower right hand corner of $A^{-1}$ and stare at it.
554+
555+
```{code-cell} ipython3
556+
with np.printoptions(precision=3, suppress=True):
557+
print(A_inv[72:,72:])
558+
```
559+
560+
561+
Notice how every row ends with the previous row's pre-diagonal entries.
562+
563+
564+
565+
566+
567+
Since $A^{-1}$ is lower triangular, each row represents $ y_t$ for a particular $t$ as the sum of
568+
- a time-dependent function $A^{-1} b$ of the initial conditions incorporated in $b$, and
569+
- a weighted sum of current and past values of the IID shocks $\{u_t\}$
570+
571+
Thus, let $\tilde{A}=A^{-1}$.
572+
573+
Evidently, for $t\geq0$,
574+
575+
$$
576+
y_{t+1}=\sum_{i=1}^{t+1}\tilde{A}_{t+1,i}b_{i}+\sum_{i=1}^{t}\tilde{A}_{t+1,i}u_{i}+u_{t+1}
577+
$$
578+
579+
This is a **moving average** representation with time-varying coefficients.
580+
581+
Just as system {eq}`eq:eqma` constitutes a
582+
**moving average** representation for $y$, system {eq}`eq:eqar` constitutes an **autoregressive** representation for $y$.
583+
584+
585+
586+
528587
## A Forward Looking Model
529588
530589
Samuelson’s model is **backwards looking** in the sense that we give it **initial conditions** and let it

0 commit comments

Comments
 (0)