Skip to content

Commit 465d762

Browse files
committed
feedback part 3
1 parent 67ec83d commit 465d762

File tree

2 files changed

+61
-25
lines changed

2 files changed

+61
-25
lines changed

examples/time_series/Time_Series_Generative_Graph.ipynb

Lines changed: 40 additions & 20 deletions
Large diffs are not rendered by default.

examples/time_series/Time_Series_Generative_Graph.myst.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,16 @@ rng = np.random.default_rng(42)
7171

7272
We start by encoding the generative graph of the AR(2) model as a function `ar_dist`. The strategy is to pass this function as a custom distribution via {class}`~pymc.CustomDist` inside a PyMC model.
7373

74-
We need to specify the initial state (`ar_init`), the autoregressive coefficients (`rho`), and the standard deviation of the noise (`sigma`). Given such parameters, we can define the generative graph of the AR(2) model using the {func}`scan <pytensor.scan.basic.scan>` operation.
74+
We need to specify the initial state (`ar_init`), the autoregressive coefficients (`rho`), and the standard deviation of the noise (`sigma`). Given such parameters, we can define the generative graph of the AR(2) model using the {meth}`scan <pytensor.scan.basic.scan>` operation.
7575

7676
:::{admonition} **What are all of these functions?**
7777
:class: note
7878

7979
At first, it might seem a bit overwhelming to see all these functions. However, they are just helper functions to define the generative graph of the AR(2) model.
8080

81-
- {func}`~pymc.pytensorf.collect_default_updates` tells PyMC that the random variable (RV) in the generative graph should be updated in every iteration of the loop.
81+
- {meth}`~pymc.pytensorf.collect_default_updates` tells PyMC that the random variable (RV) in the generative graph should be updated in every iteration of the loop.
8282

83-
- {func}`scan <pytensor.scan.basic.scan>` is an efficient way to loop inside a PyMC model. It is similar to the `for` loop in Python, but it is optimized for `pytensor`. We need to specify the following arguments:
83+
- {meth}`scan <pytensor.scan.basic.scan>` is an efficient way to loop inside a PyMC model. It is similar to the `for` loop in Python, but it is optimized for `pytensor`. We need to specify the following arguments:
8484

8585
- `fn`: The function that defines the transition steep.
8686
- `outputs_info`: The is the list of variables or dictionaries describing the initial state of the outputs computed recurrently.
@@ -274,7 +274,7 @@ ax.set_xlabel("time")
274274
ax.set_title("AR(2) Posterior Predictive Samples", fontsize=18, fontweight="bold");
275275
```
276276

277-
Overall, we the model is capturing the global dynamics of the time series. In order to have a abetter insight of the model, we can plot a subset of the posterior samples and compare them with the observed data.
277+
Overall, we see the model is capturing the global dynamics of the time series. In order to have a better insight of the model, we can plot a subset of the posterior samples and compare them with the observed data.
278278

279279
```{code-cell} ipython3
280280
fig, ax = plt.subplots(
@@ -291,8 +291,24 @@ ax[-1].set_xlabel("time")
291291
fig.suptitle("AR(2) Posterior Predictive Samples", fontsize=18, fontweight="bold", y=1.05);
292292
```
293293

294+
:::{admonition} **Conditional and Unconditional Posteriors**
295+
:class: warning
296+
297+
Many users will be surprised by this posterior because they are used to seeing conditional one-step forecasts, that is
298+
299+
$$
300+
P(x_{t} \: | \: \{ x_{\tau} \}_{\tau = 1} ^{t - 1})
301+
$$
302+
303+
304+
(what you get in statsmodels/stata/everything), which are much tighter and follow the data more closely.
305+
306+
:::
307+
308+
+++
309+
294310
## Authors
295-
- Authored by [Juan Orduz](https://juanitorduz.github.io/) and [Ricardo Vieira](https://github.com/ricardoV94) in March 2024
311+
- Authored by [Jesse Grabowski](https://github.com/jessegrabowski), [Juan Orduz](https://juanitorduz.github.io/) and [Ricardo Vieira](https://github.com/ricardoV94) in March 2024
296312

297313
+++
298314

0 commit comments

Comments
 (0)