@@ -21,16 +21,13 @@ kernelspec:
21
21
:::
22
22
23
23
``` {code-cell} ipython3
24
- import aesara as at
25
24
import arviz as az
26
- import matplotlib.dates as mdates
27
25
import matplotlib.pyplot as plt
28
26
import numpy as np
29
27
import pandas as pd
30
28
import pymc as pm
31
29
import statsmodels.api as sm
32
30
33
- from IPython.display import HTML, display
34
31
from pymc.sampling_jax import sample_blackjax_nuts
35
32
```
36
33
@@ -315,12 +312,12 @@ def plot_ppc(idata, df, group="posterior_predictive"):
315
312
axs = axs.flatten()
316
313
ppc = az.extract_dataset(idata, group=group, num_samples=100)["obs"]
317
314
# Minus the lagged terms and the constant
318
- shade_background(ppc, axs, 0, "magma ")
315
+ shade_background(ppc, axs, 0, "viridis ")
319
316
axs[0].plot(np.arange(ppc.shape[0]), ppc[:, 0, :].mean(axis=1), color="cyan", label="Mean")
320
317
axs[0].plot(df["x"], "o", color="black", markersize=6, label="Observed")
321
318
axs[0].set_title("VAR Series 1")
322
319
axs[0].legend()
323
- shade_background(ppc, axs, 1, "magma ")
320
+ shade_background(ppc, axs, 1, "viridis ")
324
321
axs[1].plot(df["y"], "o", color="black", markersize=6, label="Observed")
325
322
axs[1].plot(np.arange(ppc.shape[0]), ppc[:, 1, :].mean(axis=1), color="cyan", label="Mean")
326
323
axs[1].set_title("VAR Series 2")
@@ -399,12 +396,12 @@ def plot_ppc_macro(idata, df, group="posterior_predictive"):
399
396
axs = axs.flatten()
400
397
ppc = az.extract_dataset(idata, group=group, num_samples=100)["obs"]
401
398
402
- shade_background(ppc, axs, 0, "magma ")
399
+ shade_background(ppc, axs, 0, "inferno ")
403
400
axs[0].plot(np.arange(ppc.shape[0]), ppc[:, 0, :].mean(axis=1), color="cyan", label="Mean")
404
401
axs[0].plot(df["dl_gdp"], "o", color="black", markersize=6, label="Observed")
405
402
axs[0].set_title("Differenced and Logged GDP")
406
403
axs[0].legend()
407
- shade_background(ppc, axs, 1, "magma ")
404
+ shade_background(ppc, axs, 1, "inferno ")
408
405
axs[1].plot(df["dl_cons"], "o", color="black", markersize=6, label="Observed")
409
406
axs[1].plot(np.arange(ppc.shape[0]), ppc[:, 1, :].mean(axis=1), color="cyan", label="Mean")
410
407
axs[1].set_title("Differenced and Logged Consumption")
@@ -534,18 +531,7 @@ idata_full_test
534
531
We can see how the structure of the model has grown quite complicated.
535
532
536
533
``` {code-cell} ipython3
537
- gv = pm.model_to_graphviz(model_full_test)
538
- gv.render(filename="full_model", format="png");
539
- ```
540
-
541
- ``` {code-cell} ipython3
542
- display(
543
- HTML(
544
- """<div style='width: 4500px; overflow: scroll;'>
545
- <img src="../examples/time_series/full_model.png" alt="Model Structure">
546
- </div>"""
547
- )
548
- )
534
+ pm.model_to_graphviz(model_full_test)
549
535
```
550
536
551
537
``` {code-cell} ipython3
@@ -645,7 +631,7 @@ We can see these estimates of the correlations between the 3 economic variables
645
631
countries = gdp_hierarchical["country"].unique()
646
632
# countries = ["Ireland", "United States"]
647
633
648
- fig, axs = plt.subplots(8, 3, figsize=(20, 30 ))
634
+ fig, axs = plt.subplots(8, 3, figsize=(20, 40 ))
649
635
for ax, country in zip(axs, countries):
650
636
temp = pd.DataFrame(
651
637
idata_full_test["observed_data"][f"obs_{country}"].data,
@@ -655,7 +641,7 @@ for ax, country in zip(axs, countries):
655
641
f"obs_{country}"
656
642
]
657
643
for i in range(3):
658
- shade_background(ppc, ax, i, "magma ")
644
+ shade_background(ppc, ax, i, "inferno ")
659
645
ax[0].plot(np.arange(ppc.shape[0]), ppc[:, 0, :].mean(axis=1), color="cyan", label="Mean")
660
646
ax[0].plot(temp["dl_gdp"], "o", color="black", markersize=4, label="Observed")
661
647
ax[0].set_title(f"Posterior Predictive GDP: {country}")
0 commit comments