# Trace plots Hierarchical Models

**URL:** <https://discourse.pymc.io/t/trace-plots-hierarchical-models/5548>\
**Category:** Questions\
**Created:** [July 30, 2020, 9:04pm UTC](https://discourse.pymc.io/t/trace-plots-hierarchical-models/5548 "2020-07-30T21:04:28Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![divas\_verma](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/divas_verma/32/2947_2.png) [@divas\_verma](https://discourse.pymc.io/u/divas_verma)\
**Post date:** [July 30, 2020, 9:04pm UTC](https://discourse.pymc.io/t/trace-plots-hierarchical-models/5548/1 "2020-07-30T21:04:28Z")

</div>

Hi All,  
I am trying to explore a hierarchical model with 3 levels. I am able to create the model and generate samples from it. However, when I try to use pm.traceplot() or pm.summary() I get the following error

ValueError: Input dimension mis-match. (input[3].shape[0] = 1860, input[4].shape[0] = 900)

Any idea why this is happening and how to resolve this??

---

<div class="post-metadata">

**Author:** ![nkaimcaudle](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/nkaimcaudle/32/2142_2.png) [@nkaimcaudle](https://discourse.pymc.io/u/nkaimcaudle)\
**Post date:** [July 31, 2020, 7:01am UTC](https://discourse.pymc.io/t/trace-plots-hierarchical-models/5548/2 "2020-07-31T07:01:46Z")

</div>

You may have inconsistent versions of PyMC3 and ArviZ. How did you install them?

Also can you try the functions native in ArviZ

```
import arviz as az
az.summary()
az.plot_trace()
```

---

<div class="post-metadata">

**Author:** ![divas\_verma](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/divas_verma/32/2947_2.png) [@divas\_verma](https://discourse.pymc.io/u/divas_verma)\
**Post date:** [July 31, 2020, 2:50pm UTC](https://discourse.pymc.io/t/trace-plots-hierarchical-models/5548/3 "2020-07-31T14:50:01Z")

</div>

I tried using these commands and it is still giving me the same error.  
I am using PyMC3 3.8 and ArviZ 0.9.

---

<div class="post-metadata">

**Author:** ![nkaimcaudle](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/nkaimcaudle/32/2142_2.png) [@nkaimcaudle](https://discourse.pymc.io/u/nkaimcaudle)\
**Post date:** [August 1, 2020, 12:42am UTC](https://discourse.pymc.io/t/trace-plots-hierarchical-models/5548/4 "2020-08-01T00:42:24Z")

</div>

Can you paste an example that shows the error?

Also you can try updating both ArviZ and PyMC from the github master branch

---

<div class="post-metadata">

**Author:** ![AlexAndorra](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/alexandorra/32/9142_2.png) [@AlexAndorra](https://discourse.pymc.io/u/AlexAndorra)\
**Post date:** [August 3, 2020, 9:08am UTC](https://discourse.pymc.io/t/trace-plots-hierarchical-models/5548/5 "2020-08-03T09:08:59Z")

</div>

You can also just update PyMC to 3.9.3 from pip or conda-forge

---

<div class="post-metadata">

**Author:** ![divas\_verma](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/divas_verma/32/2947_2.png) [@divas\_verma](https://discourse.pymc.io/u/divas_verma)\
**Post date:** [August 5, 2020, 2:54am UTC](https://discourse.pymc.io/t/trace-plots-hierarchical-models/5548/6 "2020-08-05T02:54:08Z")

</div>

I tried updating the both ArviZ and PyMC but I am still getting the following error

ValueError: Input dimension mis-match. (input[3].shape[0] = 1860, input[4].shape[0] = 900)  
Apply node that caused the error: Elemwise{Composite{Switch(i0, (i1 \* ((-(i2 \* sqr((i3 - ((i4 \* i5) + i6 + (i7 \* i8) + (i9 \* i8) + i10 + (i11 \* i12) + i13 + i14 + (i15 \* i16) + (i17 \* i18 \* i8)))))) + i19)), i20)}}[(0, 4)](Elemwise{Composite{Cast{int8}(GT(i0, i1))}}.0, TensorConstant{(1,) of 0.5}, Elemwise{Composite{inv(sqr(i0))}}[(0, 0)].0, TensorConstant{[3.3082953…7540281]}, AdvancedSubtensor1.0, \<TensorType(float64, vector)\>, AdvancedSubtensor1.0, AdvancedSubtensor1.0, \<TensorType(float64, vector)\>, AdvancedSubtensor1.0, AdvancedSubtensor1.0, InplaceDimShuffle{x}.0, \<TensorType(float64, vector)\>, AdvancedSubtensor1.0, AdvancedSubtensor1.0, InplaceDimShuffle{x}.0, \<TensorType(float64, vector)\>, AdvancedSubtensor1.0, \<TensorType(float64, vector)\>, Elemwise{Composite{log((i0 \* i1))}}.0, TensorConstant{(1,) of -inf})  
Toposort index: 15  
Inputs types: [TensorType(int8, (True,)), TensorType(float64, (True,)), TensorType(float64, (True,)), TensorType(float64, vector), TensorType(float64, vector), TensorType(float64, vector), TensorType(float64, vector), TensorType(float64, vector), TensorType(float64, vector), TensorType(float64, vector), TensorType(float64, vector), TensorType(float64, (True,)), TensorType(float64, vector), TensorType(float64, vector), TensorType(float64, vector), TensorType(float64, (True,)), TensorType(float64, vector), TensorType(float64, vector), TensorType(float64, vector), TensorType(float64, (True,)), TensorType(float32, (True,))]  
Inputs shapes: [(1,), (1,), (1,), (1860,), (900,), (900,), (900,), (900,), (900,), (900,), (900,), (1,), (900,), (900,), (900,), (1,), (900,), (900,), (900,), (1,), (1,)]  
Inputs strides: [(1,), (8,), (8,), (8,), (8,), (8,), (8,), (8,), (8,), (8,), (8,), (8,), (8,), (8,), (8,), (8,), (8,), (8,), (8,), (8,), (4,)]  
Inputs values: [array([1], dtype=int8), array([0.5]), array([2.19361905]), ‘not shown’, ‘not shown’, ‘not shown’, ‘not shown’, ‘not shown’, ‘not shown’, ‘not shown’, ‘not shown’, array([0.10929279]), ‘not shown’, ‘not shown’, ‘not shown’, array([0.2955149]), ‘not shown’, ‘not shown’, ‘not shown’, array([-1.05232435]), array([-inf], dtype=float32)]  
Outputs clients: [[‘output’]]

HINT: Re-running with most Theano optimization disabled could give you a back-trace of when this node was created. This can be done with by setting the Theano flag ‘optimizer=fast\_compile’. If that does not work, Theano optimizations can be disabled with ‘optimizer=None’.  
HINT: Use the Theano flag ‘exception\_verbosity=high’ for a debugprint and storage map footprint of this apply node.

---

<div class="post-metadata">

**Author:** ![nkaimcaudle](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/nkaimcaudle/32/2142_2.png) [@nkaimcaudle](https://discourse.pymc.io/u/nkaimcaudle)\
**Post date:** [August 5, 2020, 6:25am UTC](https://discourse.pymc.io/t/trace-plots-hierarchical-models/5548/7 "2020-08-05T06:25:46Z")

</div>

We really need to see some code to be able to assist more. It looks to be a problem with the model and sampling rather than plotting and summary statistics.

---

<div class="post-metadata">

**Author:** ![OriolAbril](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/oriolabril/32/2497_2.png) [@OriolAbril](https://discourse.pymc.io/u/OriolAbril)\
**Post date:** [August 7, 2020, 3:54pm UTC](https://discourse.pymc.io/t/trace-plots-hierarchical-models/5548/8 "2020-08-07T15:54:09Z")

</div>

It is difficult to guess without seeing any model code not the complete error message, but here are some ideas:

- issues retrieving the log likelihood. see [DE-Metropolis with blackbox likelihood does not terminate](https://discourse.pymc.io/t/de-metropolis-with-blackbox-likelihood-does-not-terminate/5360/8)
- issues with densitydist and multiple observations: see [Blackbox likelihood example doesn't work](https://discourse.pymc.io/t/blackbox-likelihood-example-doesnt-work/5378)
- version issues: if mixing pip and conda, it could be that even when a newer version is installed, python is actually importing the old version anyways. check `pm. __version__ ` and `az. __version__ ` within the same code the model is executed
- issues with coordinates: it could be if using dims and coords that a the length of the array of coordinate values for a given dim does not match the size of the dimension. The error should not mention theano in this case but who knows 🤷‍♂️
- something else entirely: I don’t think we will be able to help any further than this without the code or a reduced version of it reproducing the same issue
