# 4d parameter array from PyJAGS into ArviZ?

**URL:** <https://discourse.pymc.io/t/4d-parameter-array-from-pyjags-into-arviz/16967>\
**Category:** General\
**Tags:** arviz\
**Created:** [May 1, 2025, 3:22pm UTC](https://discourse.pymc.io/t/4d-parameter-array-from-pyjags-into-arviz/16967 "2025-05-01T15:22:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cjp](https://avatars.discourse-cdn.com/v4/letter/c/9f8e36/32.png) [@cjp](https://discourse.pymc.io/u/cjp)\
**Post date:** [May 1, 2025, 3:22pm UTC](https://discourse.pymc.io/t/4d-parameter-array-from-pyjags-into-arviz/16967/1 "2025-05-01T15:22:00Z")

</div>

Hi all,

Let me know if there is a better place to post this.

I’m trying to convert sample output from PyJAGS into an ArviZ InferenceData object using arviz.from\_pyjags(), but this fails with ValueError: too many values to unpack (expected 3).

This is my call:

data = az.from\_pyjags(  
posterior=samples,  
log\_likelihood={“y”: “log\_lik”  
)

It clearly fails because one of my parameters is 4d while ArviZ expects 3. This is the parameter in question:

Variable: b.friend, Shape: (43, 43, 5000, 3), Type: \<class ‘numpy.ndarray’\>

The 4 items are (dimension1, dimension2, draws, chains)

Is there a way around this beyond coercing my 2 dimensions into 1?

ArviZ 0.21.0, pyjags 1.3.8

Thanks

---

<div class="post-metadata">

**Author:** ![Dekermanjian](https://avatars.discourse-cdn.com/v4/letter/d/96bed5/32.png) [@Dekermanjian](https://discourse.pymc.io/u/Dekermanjian)\
**Post date:** [May 1, 2025, 9:19pm UTC](https://discourse.pymc.io/t/4d-parameter-array-from-pyjags-into-arviz/16967/2 "2025-05-01T21:19:34Z")

</div>

Hi, @cjp!

While I have never used pyjags and this may be tedious, you can potentially create the InferenceData object manually. For example:

```auto
import arviz as az
import xarray as xr
import numpy as np

arr = np.random.normal(loc=0, scale=1, size=(43, 43, 5000, 3))

idata = az.InferenceData(
    posterior = xr.Dataset(
        {"b.friend": (['dimension1', 'dimension2', 'draw', 'chain'], arr)},
        coords={
            "dimension1": ("dimension1", np.arange(43)),
            "dimension2": ("dimension1", np.arange(43)),
            "draw": ("draw", np.arange(5000)),
            "chain": ("chain", np.arange(3)),
        }
    )
)

```
