I am trying to plot a conditional posterior probability using ArviZ.
Imagine I have an InferenceData
object of some sort, that I have obtained via an Markov Chain.
For instance, let us assume that I have two variables: a discrete variable $u$, that take values into $\left{-1, 1\right}$ and a continuous variable $x$ that, conditionally on $u$, is drawn from $\mathcal{N}\left(-10, 1\right)$ if $u = -1$ and from $\mathcal{N}\left(10, 1\right)$ if $u = 1$.
My goal is to plot the conditional posterior distribution for $x$ in the two cases. In other words, I would like to obtain two distinct plots for the two cases.
I have insofar tried to slice the ArviZ object, using the xarray syntax. But it is not working.
If we name the instance mcmc
(which I have created from a dictionary), I obtain that it is an arviz.InferenceData
object. It contains two dimensions: chain: 3 (for instance) and draw: 2000. Then, I have the Coordinates, the Data variables and the Attributes.
Selecting the Data variables (mcmc.posterior
) and then slicing using the class method sel
from xarray
does not yiel the conditional posterior distribution.
How should I proceed?