Hello,

I am reading the manual and I don’t understand why the logical (or integer) matrix can’t be a parameter.

I have to use it, does anybody have a solution?

Thank you for the help,

Rincourt

Hello,

I am reading the manual and I don’t understand why the logical (or integer) matrix can’t be a parameter.

I have to use it, does anybody have a solution?

Thank you for the help,

Rincourt

Because any Hamiltonian Monte Carlo scheme relies on derivatives and you cannot differentiate with respect to something that is defined on a discrete parameter space.

You can integrate those parameters out of the posterior distribution, leaving a posterior distribution that only depends on continuous unknowns, but it will probably be tedious if there are many such discrete unknowns. There are examples in the Stan User Manual and at

Thank you for the link, it is really helpful !

I’m going to try it.

I have another problem, in the transformed parameter chunk. I have an indicator number defined by idx= N*P/2 (P is an even number).

But stan doesn’t understand idx as an integer.

How can I fix this ?

If `N`

and `P`

are both integers, then so is `N * P / 2`

because the Stan language uses integer division. You might get a parser warning about it rounding down, but it won’t round down if `P`

is even.