multinom/categorical support 0:(N-1) vs. 1:N?

13 views
Skip to first unread message

Bob Carpenter

unread,
Nov 12, 2012, 4:31:48 PM11/12/12
to stan...@googlegroups.com
The categorical and multinomial distributions in Stan
are currently coded for outcomes in 0:(N-1). But
they're documented in the manual as taking outcomes
1:N, so something has to be done to make the doc consistent
with the implementation.

Should we change categorical and multinomial are in 1:N?

Pro: would bring Stan in line with BDA, R, and BUGs

Con: breaks backward compatiblity for existing categorical()
and multinomial()

Over the long haul, I think it's worth changing. I think
we could fudge updating major version number by calling
it a bug fix, but I'm not too hung up on version numbering one
way or another.

In terms of models, only the BUGS model

src/models/bugs_examples/vol1/inhalers/inhalers.stan

uses it, and uses the following line to bring it back in
line with the BUGS data:

response[i, t] - 1 ~ categorical(p[i, t]);

It's also used in eyes.stan as is (without the -1):

src/models/bugs_examples/vol2/eyes/eyes.stan

The multinomial() isn't used anywhere. It could've been used
in:

src/models/bugs_examples/vol2/endo/endo2.stan

but the model was coded directly in terms of its probability
function using lp__ instead of multinomial() -- was this because
mulitnomial()'s behavior was confusing?

- Bob

Jiqiang Guo

unread,
Nov 12, 2012, 7:48:02 PM11/12/12
to stan...@googlegroups.com
We talked about this before.



On Mon, Nov 12, 2012 at 4:31 PM, Bob Carpenter <ca...@alias-i.com> wrote:
but the model was coded directly in terms of its probability
function using lp__ instead of multinomial() -- was this because
mulitnomial()'s behavior was confusing?

I guess I coded that example, and I cannot recall why.  Maybe it is 
just because in this case using  lp__ is neat or I wanted to try 
using lp__ back then. 

--
Jiqiang

Bob Carpenter

unread,
Nov 13, 2012, 1:36:05 AM11/13/12
to stan...@googlegroups.com
We discussed it but it doesn't look like we came
to any conclusion (other than the de facto one of
0:(N-1) in the implementation).

BDA only has a multinomial, but the implied indexing
is 1:N because that's the indexing in the outcome vector.

- Bob
> --
>
>
Reply all
Reply to author
Forward
0 new messages