Each sample is associated with 1 group and 1 condition (coordinates in the trace).
For the purpose of this example, the following results are only considering 1 chain, and 1 condition (coordinate of the trace).
I am using Arviz.InferenceData to plot the trace of samples for a конкретная переменная a_kg (где каждая строка представляет одну группу):
Код: Выделить всё
import arviz as az
# trace variable coming from pymc3.sample
azdata = az.from_pymc3(
trace=trace,
coords={'group': groups, 'condition': conditions},
dims={'a_kg': ['group', 'condition']}
)
azdata_sel = azdata.sel(chain=[0], condition='Control')
az.plot_trace(azdata_sel, var_names=['a_kg'], divergences='bottom');

If I understood correctly, the divergences are shown on the bottom of the traces with a rug plot.
If this is correct, there is a divergence around draw 30.
Therefore, I get a slice of samples that has at least one divergence (in this case the slice containing sample 30) to explore this part of the trace in greater detail.
Код: Выделить всё
azdata_sel = azdata.sel(draw=slice(25, 35))
az.plot_trace(azdata_sel, var_names=['a_kg'], divergences='bottom')

I would like to identify why the chain diverges to understand better how this model works. However, when I look at the samples for variable a_kg, for each group, around draw 30, all values are restricted in a narrow, finite range:
Код: Выделить всё
array([[7.03689753e+01, 7.08419788e+01, 4.18270946e+01, 5.56815107e+01,
2.89069656e+01, 3.21847218e+01, 1.72809154e+01, 6.80358410e+00,
8.27741780e+00, 8.61561309e+00, 9.52030649e+00, 7.42601279e+00,
4.86924384e+00, 4.65123572e+00, 3.42272331e+00, 3.72094392e+00,
3.79496877e+00, 3.63692105e+00, 4.53843102e+00, 4.49938710e+00,
1.16647181e+00, 1.57530039e+00, 1.38785612e+00, 2.93999569e+00,
3.19698360e-01, 1.09373256e+00, 8.91772857e-01, 1.27258163e+00,
7.30115016e-01, 6.48975286e-01, 9.53344198e-01, 7.10095320e-01,
1.94587869e-01, 2.37110242e-01, 1.74995857e-02, 1.09717525e-01,
2.49860304e-01, 1.73485239e-01, 3.15215749e-01]])
Подробнее здесь: https://stackoverflow.com/questions/668 ... sing-arviz
Мобильная версия