Plot posterior predictive several coordinates

I have just realized where my problem was with the likelyhood, I had to give it the two dimensions:

    like_fo = pm.Normal('like_fo',
                        mu=mu_fo,
                        sd=sd_fo,
                        dims=('step','resid'),
                        observed=df_5vk6)

@AlexAndorra
I didn’t know about the return_inferencedata option. This is very handy. Can I append to the xarray that is generated the ppc data so I can save it all together to disk?

@OriolAbril
Not having the image made me miss it, good thing you guys are aware of this. I am still running into a small problem. If I do this:

az.plot_ppc(my_model, flatten = [])
```python
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-39-ddd74f183c7b> in <module>
----> 1 az.plot_ppc(my_model, flatten = [])

~/data_partition/bin2/anaconda3/envs/nmr_assign_state/lib/python3.8/site-packages/arviz/plots/ppcplot.py in plot_ppc(data, kind, alpha, mean, figsize, textsize, data_pairs, var_names, filter_vars, coords, flatten, flatten_pp, num_pp_samples, random_seed, jitter, animated, animation_kwargs, legend, ax, backend, backend_kwargs, group, show)
    336     # TODO: Add backend kwargs
    337     plot = get_plotting_function("plot_ppc", "ppcplot", backend)
--> 338     axes = plot(**ppcplot_kwargs)
    339     return axes

~/data_partition/bin2/anaconda3/envs/nmr_assign_state/lib/python3.8/site-packages/arviz/plots/backends/matplotlib/ppcplot.py in plot_ppc(ax, length_plotters, rows, cols, figsize, animated, obs_plotters, pp_plotters, predictive_dataset, pp_sample_ix, kind, alpha, linewidth, mean, xt_labelsize, ax_labelsize, jitter, total_pp_samples, legend, group, markersize, animation_kwargs, num_pp_samples, backend_kwargs, show)
    160                     new_d = np.zeros((rep, len_density))
    161                     bins = np.digitize(pp_xs, new_x, right=True)
--> 162                     new_x -= (new_x[1] - new_x[0]) / 2
    163                     for irep in range(rep):
    164                         new_d[irep][bins[irep]] = pp_densities[irep]

IndexError: index 1 is out of bounds for axis 0 with size 1

I get something similar if I add coords={'resid': [64]}.

1 Like