# Eigen error when initializing simplex parameter

**URL:** <https://discourse.mc-stan.org/t/eigen-error-when-initializing-simplex-parameter/14104>\
**Category:** General\
**Created:** [April 5, 2020, 6:32pm UTC](https://discourse.mc-stan.org/t/eigen-error-when-initializing-simplex-parameter/14104 "2020-04-05T18:32:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![caesoma](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/caesoma/32/19767_2.png) [@caesoma](https://discourse.mc-stan.org/u/caesoma)\
**Post date:** [April 5, 2020, 6:32pm UTC](https://discourse.mc-stan.org/t/eigen-error-when-initializing-simplex-parameter/14104/1 "2020-04-05T18:32:44Z")

</div>

I am getting and Eigen error when trying to provide initial chain values when using a simplex parameter:

`ERRORAssertion failed: (index >= 0 && index < size()), function operator[], file stan/lib/stan_math/lib/eigen_3.3.3/Eigen/src/Core/DenseCoeffsBase.h, line 408.`

Runs without the `inits` argument seem to start without issues, not using the simplex variable and providing `inits` also seems to start the chain. I am using CmdStanPy. Thanks.

---

<div class="post-metadata">

**Author:** ![rok\_cesnovar](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@rok\_cesnovar](https://discourse.mc-stan.org/u/rok_cesnovar)\
**Post date:** [April 7, 2020, 3:30pm UTC](https://discourse.mc-stan.org/t/eigen-error-when-initializing-simplex-parameter/14104/2 "2020-04-07T15:30:07Z")

</div>

This implies that you are trying to acces elements wiht index out of bounds. Too many init values maybe?

---

<div class="post-metadata">

**Author:** ![caesoma](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/caesoma/32/19767_2.png) [@caesoma](https://discourse.mc-stan.org/u/caesoma)\
**Post date:** [April 7, 2020, 4:54pm UTC](https://discourse.mc-stan.org/t/eigen-error-when-initializing-simplex-parameter/14104/3 "2020-04-07T16:54:02Z")

</div>

I got that much from googling the error for Eigen, but the simplex documentation is not clear on that. Should the `inits` for a simplex of size `K` have `K-1` elements?

---

<div class="post-metadata">

**Author:** ![nhuurre](https://avatars.discourse-cdn.com/v4/letter/n/ad7895/32.png) [@nhuurre](https://discourse.mc-stan.org/u/nhuurre)\
**Post date:** [April 7, 2020, 5:11pm UTC](https://discourse.mc-stan.org/t/eigen-error-when-initializing-simplex-parameter/14104/4 "2020-04-07T17:11:26Z")

</div>

> [@caesoma](#):
>
> Should the `inits` for a simplex of size `K` have `K-1` elements?

`K` elements. But I’m afraid the problem is [this bug](https://github.com/stan-dev/stanc3/issues/485) which makes `inits` not work for some constrained types.

---

<div class="post-metadata">

**Author:** ![caesoma](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/caesoma/32/19767_2.png) [@caesoma](https://discourse.mc-stan.org/u/caesoma)\
**Post date:** [April 7, 2020, 9:34pm UTC](https://discourse.mc-stan.org/t/eigen-error-when-initializing-simplex-parameter/14104/5 "2020-04-07T21:34:33Z")

</div>

I see, it’s not something that can be fixed in the Stan code, then, I presume. Thanks.
