Loglikelihood of posterior predictive samples

for plot_loo_pit you can use loo_pit, for bpv but they can be calculated in 1-2 lines, either with xarray itself or with xarray-einstats (whose introductory blogpost I still have to write).

The raw data for the last example can be generated from something like:

obs_t = data.observed_data.quantile(.5)
pp_t = data.posterior_predictive.quantile(.5, dim=("y_dim_0"))
bpv = (pp_t >= obs_t).mean()

We also have arviz.apply_test_function — ArviZ dev documentation for functions that take a 1d array to help apply them with chain and draw as batch dimensions so it works on both observed_data and posterior_predictive at the same time.

1 Like