Run Multiple Rstan Processes

118 views
Skip to first unread message

Yong Luo

unread,
Jul 7, 2014, 1:02:20 PM7/7/14
to stan-...@googlegroups.com
Hi there,

Would it be ok to run multiple Rstan processes at the same time on a Windows PC? I tried to run several R2Openbugs processes simultaneously and found that the results seem to be very similar, even though the generating values were very different.

Thanks!
Yong

Avraham Adler

unread,
Jul 7, 2014, 1:18:44 PM7/7/14
to stan-...@googlegroups.com

What is being used to make the process parallel? Most of the R packages for parallel processing do not work on Windows and only call one thread.

Avi

Yong Luo

unread,
Jul 7, 2014, 1:21:37 PM7/7/14
to stan-users
Hi Avi,

What I meant is not parallel processing, but opening multiple R interfaces to run several Rstan programs at the same time.
Sorry about the confusion...

Yong


--
You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/c8wb87yQkPc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bob Carpenter

unread,
Jul 7, 2014, 2:44:47 PM7/7/14
to stan-...@googlegroups.com
There shouldn't be a problem doing that.

You should still give the different chains the same
seed and different chain IDs.

I'm not clear on what the best way to save the fit object
in each process then read them all back in to a single process
and combine them into a single fit object for posterior analysis.
But Jiqiang or Ben should know.

- Bob
> You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.

Christian Roy

unread,
Jul 7, 2014, 3:52:50 PM7/7/14
to stan-...@googlegroups.com
You can simple save the chains themselves:

chain1 <-stan(fit=fit1, init =my.inits(), pars=params, data=data.list, warmup = 250, iter=3250, chains = 1, chain_id=1)
save(sample1, file="G:/BackupChris/mallard_spatial_model/chain1.saved")

and then  re-import them in R and combine them into a fit object. 

load("G:/BackupChris/mallard_spatial_model/chain1.saved")
...
model1 <- sflist2stanfit(list(sample1,sample2,sample3, sample4,  sample5,  sample6))
output1<-extract(model1, permuted = TRUE)

Note that if you use that method it will be really important to use the "chain_id" command otherwise some chains could be exact duplicate. 

Finally, I also had problem in the past with BUGS and JAGS so I usually run the chains in different working folders. I never tried to run many chains at the same time with Stan though so you should listen to Bob instead of me. 

Chris
------------------




Bob Carpenter

unread,
Jul 7, 2014, 3:58:04 PM7/7/14
to stan-...@googlegroups.com

On Jul 7, 2014, at 3:52 PM, Christian Roy <christia...@gmail.com> wrote:

Thanks for the response, Christian.

> ...

> Note that if you use that method it will be really important to use the "chain_id" command otherwise some chains could be exact duplicate.

W.r.t. listening to me, the above was the only point I was trying
to make --- if you use the exact same seed in different processes
you'll get the same result. And if you use the default one based
on time, they're likely to be the same seed because the processes
spin up pretty quickly these days and we're not using super fine
grained time-based seeds.

- Bob
Reply all
Reply to author
Forward
0 new messages