@iavicenna
Also, if you don’t need to change cleaned_data, then you can do the prior_predictive_check in a more simpler manner. After doing sample_prior_predictive, you can check idata[“prior_predictive”][“Y_obs”] to get the sample counts (using prior distributions) and check if they make sense directly. This will prevent any errors and perhaps better for starters to get acquainted to the results you obtain.
you mean below thing right?
import xarray as xr
import arviz as az
def plot_xY(x, Y, ax):
quantiles = Y.quantile((0.025, 0.25, 0.5, 0.75, 0.975), dim=("chain", "draw")).transpose()
az.plot_hdi(
x,
hdi_data=quantiles.sel(quantile=[0.025, 0.975]),
fill_kwargs={"alpha": 0.25},
smooth=False,
ax=ax,
)
az.plot_hdi(
x,
hdi_data=quantiles.sel(quantile=[0.25, 0.75]),
fill_kwargs={"alpha": 0.5},
smooth=False,
ax=ax,
)
ax.plot(x, quantiles.sel(quantile=0.5), color="C1", lw=3)
figsize = (10, 5)
fig, ax = plt.subplots(figsize=figsize)
plot_xY(range(len(cleaned_data['Data_Value'])), idata.prior_predictive["Y_obs"], ax)
# format_x_axis(ax)
ax.plot(range(len(cleaned_data['Data_Value'])), cleaned_data['Data_Value'], label="observed")
ax.set(title="Prior predictive distribution")
plt.legend();
output is
