# AR model "too many indices for array"

**URL:** <https://discourse.pymc.io/t/ar-model-too-many-indices-for-array/2546>\
**Category:** Questions\
**Created:** [January 18, 2019, 12:47am UTC](https://discourse.pymc.io/t/ar-model-too-many-indices-for-array/2546 "2019-01-18T00:47:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![RJTK](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/rjtk/32/1418_2.png) [@RJTK](https://discourse.pymc.io/u/RJTK)\
**Post date:** [January 18, 2019, 12:47am UTC](https://discourse.pymc.io/t/ar-model-too-many-indices-for-array/2546/1 "2019-01-18T00:47:39Z")

</div>

I am looking into some time series models in pymc3, and am running into a lot of difficulties right out the gate with the `AR` class. Consider first the trivial example:

```auto
with pm.Model as model():
    pm.Normal("x", mu=0.0, sd=1.0)
pm.sample_prior_predictive(samples=100, model=model)

```

This works exactly as expected. I would like to do something similar with an AR model, however

```auto
with pm.Model() as model:
    pm.AR("ar", rho=[0.9], sd=5.0, constant=False,
          init=pm.Normal("x0", mu=0.0, sd=1.0))

```

fails immediately with `IndexError: too many indices for array`. I have not been able to instantiate an AR model at all unless I use `observed=data`, which is not what I want. Should my model be valid? Or do I have some problem?

Edit: This is on pymc3 3.6, Theano 1.0.3. with a more detailed trace:

```auto
.../theano/tensor/var.py in __getitem__ (self, args)
    508 # Check if the number of dimensions isn't too large.
    509 if self.ndim < index_dim_count:
--> 510 raise IndexError('too many indices for array')
    511 
    512 # Convert an Ellipsis if provided into an appropriate number of

```

---

<div class="post-metadata">

**Author:** ![junpenglao](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/junpenglao/32/8_2.png) [@junpenglao](https://discourse.pymc.io/u/junpenglao)\
**Post date:** [January 18, 2019, 5:43am UTC](https://discourse.pymc.io/t/ar-model-too-many-indices-for-array/2546/2 "2019-01-18T05:43:50Z")

</div>

You need to provide `shape` (AR could not figure this out dynamically) and pass a distribution (instead of a RandomVariable) to init:

```auto
with pm.Model() as model:
    pm.AR("ar", rho=[0.9], sd=5.0, constant=False,
          init=pm.Normal.dist(mu=0.0, sd=1.0), shape=100)

```
