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/ar1_turningpts.md
+49-52Lines changed: 49 additions & 52 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,9 +31,9 @@ We consider two sorts of statistics:
31
31
32
32
- prospective values $y_{t+j}$ of a random process $\{y_t\}$ that is governed by the AR(1) process
33
33
34
-
- sample path properties that are defined as non-linear functions of future values $\{y_{t+j}\}_{j \geq 1}$ at time $t$.
34
+
- sample path properties that are defined as non-linear functions of future values $\{y_{t+j}\}_{j \geq 1}$ at time $t$
35
35
36
-
**Sample path properties** are things like "time to next turning point" or "time to next recession"
36
+
**Sample path properties** are things like "time to next turning point" or "time to next recession".
37
37
38
38
To investigate sample path properties we'll use a simulation procedure recommended by Wecker {cite}`wecker1979predicting`.
39
39
@@ -43,17 +43,14 @@ Let's start with some imports.
43
43
44
44
```{code-cell} ipython3
45
45
import numpy as np
46
-
47
46
import arviz as az
48
47
import pymc as pmc
49
-
50
48
import matplotlib.pyplot as plt
51
49
import seaborn as sns
52
50
53
51
sns.set_style('white')
54
52
colors = sns.color_palette()
55
53
56
-
57
54
import logging
58
55
logging.basicConfig()
59
56
logger = logging.getLogger('pymc')
@@ -106,9 +103,9 @@ We also want to compute some predictive distributions of "sample path statistic
106
103
- the time until the next "recession",
107
104
- the minimum value of $Y$ over the next 8 periods,
108
105
- "severe recession", and
109
-
- the time until the next turning point (positive or negative)
106
+
- the time until the next turning point (positive or negative).
110
107
111
-
To accomplish that for situations in which we are uncertain about parameter values, we shall extend the approach Wecker {cite}`wecker1979predicting` in the following way.
108
+
To accomplish that for situations in which we are uncertain about parameter values, we shall extend Wecker's {cite}`wecker1979predicting` approach in the following way.
112
109
113
110
- first simulate an initial path of length $T_0$;
114
111
- for a given prior, draw a sample of size $N$ from the posterior joint distribution of parameters $\left(\rho,\sigma\right)$ after observing the initial path;
ax[0, 1].set_title("Predictive distribution of time until the next recession", fontsize=13)
458
455
@@ -478,42 +475,42 @@ plt.show()
478
475
Now we apply we apply our "extended" Wecker method based on predictive densities of $y$ defined by
479
476
{eq}`ar1-tp-eq4` that acknowledge posterior uncertainty in the parameters $\rho, \sigma$.
480
477
481
-
To approximate the intergration on the right side of {eq}`ar1-tp-eq4`, we repeately draw parameters from the joint posterior distribution each time we simulate a sequence of future values from model {eq}`ar1-tp-eq1`.
478
+
To approximate the intergration on the right side of {eq}`ar1-tp-eq4`, we repeatedly draw parameters from the joint posterior distribution each time we simulate a sequence of future values from model {eq}`ar1-tp-eq1`.
482
479
483
480
```{code-cell} ipython3
484
481
def plot_extended_Wecker(post_samples, initial_path, N, ax):
485
482
"""
486
483
Plot the extended Wecker's predictive distribution
487
484
"""
488
-
# select a sample
489
-
index = np.random.choice(np.arange(len(post_samples['rho'])), N+1, replace=False)
485
+
# Select a sample
486
+
index = np.random.choice(np.arange(len(post_samples['rho'])), N + 1, replace=False)
Finally, we plot both the original Wecker method and the extended method with parameter values drawn from the posterior together to compare the differnces that emerge from pretending to know parameter values when they are actually uncertain.
536
+
Finally, we plot both the original Wecker method and the extended method with parameter values drawn from the posterior together to compare the differences that emerge from pretending to know parameter values when they are actually uncertain.
0 commit comments