# How to get all values from a PyMC3 parameter of shape \> 1?

**URL:** https://discourse.pymc.io/t/how-to-get-all-values-from-a-pymc3-parameter-of-shape-1/8284
**Category:** Questions
**Created:** [November 5, 2021, 10:46am UTC](https://discourse.pymc.io/t/how-to-get-all-values-from-a-pymc3-parameter-of-shape-1/8284 "2021-11-05T10:46:06Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Mreznik](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/mreznik/32/4561_2.png) [@Mreznik](https://discourse.pymc.io/u/Mreznik)
#### Post date: [November 5, 2021, 10:46am UTC](https://discourse.pymc.io/t/how-to-get-all-values-from-a-pymc3-parameter-of-shape-1/8284/1 "2021-11-05T10:46:06Z")

</div>

have built an unpooled model in PyMC3:

```auto
with pm.Model() as unpooled:

  # PRIORS
  alpha = pm.Uniform('alpha',lower=-5,upper=5, shape=len(set(Y.values)))
  beta = pm.Normal('beta',mu=0,sd=1, shape=len(set(Y.values)))
  sigma = pm.Uniform('sigma',lower=0.01,upper=3)

  # LIKLIHOOD
  e = X['flavanoids'].values * beta[Y.values.astype(int)] + alpha[Y.values.astype(int)]
  y = pm.Normal('y',mu=e, sd=sigma, observed=Y.values)

  # SAMPLE AND PLOT TRACE
  trace = pm.sample(2000)

```

I know that if the shape of `beta` was 1, I could have gotten the max probability estimate using:

```auto
ppc = pm.fast_sample_posterior_predictive(trace, samples=1_0000, var_names=['beta'])
preds = ppc['beta'].mean(0)

```

but since the shape is more than 1, I should get more the 1 value for it. how can I extract that value?

---

<div class="post-metadata">

### Author: ![cluhmann](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/cluhmann/32/3083_2.png) [@cluhmann](https://discourse.pymc.io/u/cluhmann)
#### Post date: [January 7, 2022, 3:38am UTC](https://discourse.pymc.io/t/how-to-get-all-values-from-a-pymc3-parameter-of-shape-1/8284/2 "2022-01-07T03:38:22Z")

</div>

Welcome. Sorry for the delayed response! Try this:

```python
index = 0
print((ppc['beta'][:,index]).mean())

```

If you instead work with an inferencedata object (e.g., `pm.sample(return_inferencedata=True)`) then you index things slightly differently. But the above work for the default MultiTrace object.

---

<div class="post-metadata">

### Author: ![almostmeenal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/almostmeenal/32/3723_2.png) [@almostmeenal](https://discourse.pymc.io/u/almostmeenal)
#### Post date: [January 19, 2022, 9:07am UTC](https://discourse.pymc.io/t/how-to-get-all-values-from-a-pymc3-parameter-of-shape-1/8284/3 "2022-01-19T09:07:09Z")

</div>

> [@cluhmann](#):
>
> return\_inferencedata=True

I’m not sure but I think we have changed the default return\_inferencedata as True and a warning is shown if True or False isn’t given already. Although I don’t remember if that’s a case of development version or v3
