Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mislabeled tutorial plots #269

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions docs/source/tutorials/hospital_admissions_model.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ with npro.handlers.seed(rng_seed=np.random.randint(1, timeframe)):

```{python}
# | label: fig-basic
# | fig-cap: Rt and Infections
# | fig-cap: Rt and Admissions
import matplotlib.pyplot as plt

fig, axs = plt.subplots(1, 2)
Expand All @@ -218,9 +218,9 @@ fig, axs = plt.subplots(1, 2)
axs[0].plot(sim_data.Rt)
axs[0].set_ylabel("Rt")

# Infections plot
# Admissions plot
axs[1].plot(sim_data.observed_hosp_admissions)
axs[1].set_ylabel("Infections")
axs[1].set_ylabel("Admissions")
axs[1].set_yscale("log")

fig.suptitle("Basic renewal model")
Expand Down Expand Up @@ -249,7 +249,7 @@ hosp_model.run(
)
```

We can use the `plot_posterior` method to visualize the results[^capture]:
We can use the `plot_posterior` method to visualize the results, plotting the observed values against the inferred latent values[^capture]:

[^capture]: The output is captured to avoid `quarto` from displaying the output twice.

Expand All @@ -267,7 +267,7 @@ out = hosp_model.plot_posterior(
)
```

Test `posterior_predictive` and `prior_predictive` methods to generate posterior and prior predictive samples.
Test `posterior_predictive` and `prior_predictive` methods to generate posterior and prior predictive samples for observed admissions.

```{python}
# | label: demonstrate-use-of-predictive-methods
Expand Down Expand Up @@ -572,7 +572,7 @@ Below we plot the prior predictive distributions using equal tailed bayesian cre

```{python}
# | label: fig-output-prior-predictive
# | fig-cap: Prior Predictive Infections
# | fig-cap: Prior Predictive Admissions
def compute_eti(dataset, eti_prob):
eti_bdry = dataset.quantile(
((1 - eti_prob) / 2, 1 / 2 + eti_prob / 2), dim=("chain", "draw")
Expand Down Expand Up @@ -611,17 +611,17 @@ plt.scatter(
color="black",
)

axes.set_title("Prior Predictive Infections", fontsize=10)
axes.set_title("Prior Predictive Admissions", fontsize=10)
axes.set_xlabel("Time", fontsize=10)
axes.set_ylabel("Observed Infections", fontsize=10)
axes.set_ylabel("Observed Admissions", fontsize=10)
plt.yscale("log")
plt.show()
```

And now we plot the posterior predictive distributions with a `{python} n_forecast_points`-day-ahead forecast:
```{python}
# | label: fig-output-posterior-predictive
# | fig-cap: Posterior Predictive Infections
# | fig-cap: Posterior Predictive Admissions
fig, axes = plt.subplots(figsize=(6, 5))
az.plot_hdi(
idata_weekday.posterior_predictive["negbinom_rv_dim_0"]
Expand Down Expand Up @@ -670,8 +670,8 @@ plt.scatter(
color="black",
)
axes.legend()
axes.set_title("Posterior Predictive Infections", fontsize=10)
axes.set_title("Posterior Predictive Admissions", fontsize=10)
axes.set_xlabel("Time", fontsize=10)
axes.set_ylabel("Observed Infections", fontsize=10)
axes.set_ylabel("Observed Admissions", fontsize=10)
plt.show()
```