retranslating BUGS models to Stan

63 views
Skip to first unread message

Bob Carpenter

unread,
Mar 31, 2015, 6:56:07 PM3/31/15
to stan...@googlegroups.com
[on stan-dev]

OK, so the marching orders are:

1. Directly translate WinBUGS models, warts and all. Does
that mean

a. using loops where they use loops instead of vectorizing,

b. using step functions instead of conditionals, and

c. using global transformed parameters instead of local variables
for intermediate quantities?

2. If the answers to 1a-c are positive, should we also have idiomatic and
efficient direct translations?

3. Include the models we like.

4. Include some language in the models we don't like pointing to the
ones we do like.

5. I also think it'll help to include the posterior analysis of all
of the models. For that should we use

a. WinBUGS,

b. OpenBUGS, or

c. JAGS?

That is, just how conservative are people? Is it WinBUGS or bust?

Finally, what's the priority for this vs. say getting a stiff ODE
solver into Stan? Doing this means we have to push other tasks
down the to-do list.

- Bob

Andrew Gelman

unread,
Mar 31, 2015, 7:05:00 PM3/31/15
to stan...@googlegroups.com
Hi, see responses below.

> On Mar 31, 2015, at 6:55 PM, Bob Carpenter <ca...@alias-i.com> wrote:
>
> [on stan-dev]
>
> OK, so the marching orders are:
>
> 1. Directly translate WinBUGS models, warts and all.

Only if we add comments saying where we dislike the “warts” and giving alternative.

> Does
> that mean
>
> a. using loops where they use loops instead of vectorizing,

No.

> b. using step functions instead of conditionals, and

No.

> c. using global transformed parameters instead of local variables
> for intermediate quantities?

No.

> 2. If the answers to 1a-c are positive, should we also have idiomatic and
> efficient direct translations?
>
> 3. Include the models we like.
>
> 4. Include some language in the models we don't like pointing to the
> ones we do like.
>
> 5. I also think it'll help to include the posterior analysis of all
> of the models. For that should we use
>
> a. WinBUGS,
>
> b. OpenBUGS, or
>
> c. JAGS?

I think Jags is enough.

> That is, just how conservative are people? Is it WinBUGS or bust?
>
> Finally, what's the priority for this vs. say getting a stiff ODE
> solver into Stan?

What do others think?

> Doing this means we have to push other tasks
> down the to-do list.
>
> - Bob
>
> --
> You received this message because you are subscribed to the Google Groups "stan development mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to stan-dev+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


Aki Vehtari

unread,
Apr 1, 2015, 6:59:14 AM4/1/15
to stan...@googlegroups.com, gel...@stat.columbia.edu
> > Finally, what's the priority for this vs. say getting a stiff ODE
> > solver into Stan?
>
> What do others think?

1) Make translation guidelines and couple translation examples
2) Give credits for students translating and running the model tests
3) Check that translated models really look like what you want

Aki

Sebastian Weber

unread,
Apr 1, 2015, 12:20:15 PM4/1/15
to stan...@googlegroups.com
Hi!

I think the models should run on either JAGS or WinBUGS and I would actually recommend using WinBUGS.

JAGS 3.4.0 is not able to deterministically lay out the DAG in the memory which leads to different results even when the input is exactly the same. You must be very careful when you ask for exact reproducibility with JAGS. Only in some situations the output from JAGS becomes exactly reproducible! JAGS 4.0.0 is supposed to solve this issue. Of course, statistical wise everything is fine.

Concerning importance: The suggestion from Aki sounds great, i.e. give it with guidelines to students... getting a stiff ODE solver into Stan is hopefully the number one prio...

Cheers,
Sebastian

Bob Carpenter

unread,
Apr 1, 2015, 5:24:09 PM4/1/15
to stan...@googlegroups.com
By exact reproducibility, you mean in a statistical sense or
you mean in exactly the same draws across platforms?

I'd hate to have to go back to using WinBUGS.

- Bob

Sebastian Weber

unread,
Apr 1, 2015, 6:03:34 PM4/1/15
to stan...@googlegroups.com
Statistial wise everything is always fine. Whatever you do, call your jags program twice and make sure it gives you exactly the same answer. That is, the very same sequence of mcmc draws when you repeat on the same machine consecutivley (when you expect stan to answer as well the same).

Sebastian

Bob Carpenter

unread,
Apr 1, 2015, 7:48:09 PM4/1/15
to stan...@googlegroups.com
Can you set the seed for JAGS? If not, I wouldn't expect
to get the same answers twice in a row. I also don't know
how to do that for WinBUGS. I never used either of those
pieces of software to do more than fit a couple models.

- Bob


> On Apr 2, 2015, at 9:03 AM, Sebastian Weber <sdw....@gmail.com> wrote:
>
> Statistial wise everything is always fine. Whatever you do, call your jags program twice and make sure it gives you exactly the same answer. That is, the very same sequence of mcmc draws when you repeat on the same machine consecutivley (when you expect stan to answer as well the same).
>
> Sebastian
>

Avraham Adler

unread,
Apr 1, 2015, 11:29:03 PM4/1/15
to stan...@googlegroups.com
On Wednesday, April 1, 2015 at 7:48:09 PM UTC-4, Bob Carpenter wrote:
> Can you set the seed for JAGS? If not, I wouldn't expect
> to get the same answers twice in a row. I also don't know
> how to do that for WinBUGS. I never used either of those
> pieces of software to do more than fit a couple models.
>
> - Bob

Yes, there are variables called ".RNG.seed" and ".RNG.name" which can be used to control the random variables, and if using R, both rjags and runjags allow you to pass values to JAGS in the initialization as well.

For example using runjags, you can set inits as such:

inits <- function(chain) {list(alpha.prior = 20 + rnorm(2, 0, 1), theta.prior = 1000 + rnorm(2, 0, 10), m = sample(c(1, 2, 3), size = 1, prob=c(.8, .15, .05)), .RNG.seed = chain ^ 2 + 1, .RNG.name = "base::Mersenne-Twister")}
Reply all
Reply to author
Forward
0 new messages