Is it possible to declare custom structures in Stan? For example, I am working with a dynamic HMM problem. There are 3 states, so I need a 3 x 3 matrix to contain all the parameters pertinent to each transition. Each transition has one intercept term xi, and 6 coefficients beta[6]. Is there an efficient way to capture all these in one matrix declaration and be able to work with it?

# Complex matrix structure

That gives you indexing `beta[k, i, j]`

if that’s what you want, or `beta[k]`

to pick out a matrix.

The main problem with HMMs is that those matrices have to be simplex constrained if they’re the transition matrices, so you want to use something like:

```
simplex[3] beta[K, 3];
```

Same indexing structure, `beta[k, i, j]`

, but now you are guaranteed to have a simplex. If you’re defining the matrix yourself using something like softmax over predictors, this would only give you error checking.

**bhomass**#4

Vector[3,3] beta is exactly what I need for this. I don’t really need the matrix properties except an efficient way to access the beta vectors using row and column.