14
$\begingroup$

I was wondering which software statistical package do you guys recommend for performing Bayesian Inference.

For example, I know that you can run openBUGS or winBUGS as standalones or you can also call them from R. But R also has several of its own packages (MCMCPack, BACCO) which can do bayesian analysis.

Does anybody have any suggestions as to which bayesian statistics package in R is best or about other alternatives (Matlab or Mathematica?)

The main features I am looking to compare are performance, ease of use, stability and flexibility

$\endgroup$
  • 1
    $\begingroup$ (1) I do not think there is a package that could qualify as optimal. (2) Bayesian analysis does not only include sampling. (3) These R packages are useful for sampling: Rtwalk, mcmc. They only require programming the log-posterior but no package is infallible. (4) It is well known that, under appropriate programming: R<(Matlab,Python)<C in terms of efficiency (see e.g. link). $\endgroup$ – user10525 Jul 30 '12 at 11:24
  • 2
    $\begingroup$ fair points, although re:4 - this is not necessarily true if you include development time. Also, the R-based solutions (either interfacing with R or running as R packages) are typically using C/C++ for the sampling code. $\endgroup$ – user4733 Jul 30 '12 at 11:30
  • $\begingroup$ @user4733, the C++ based solutions are 5-10x faster than BUGS variants, and much more faster than R solutions, see my answer. $\endgroup$ – Curious Aug 14 '12 at 8:47
  • $\begingroup$ similar question: stats.stackexchange.com/q/9202/5509 $\endgroup$ – Curious Sep 16 '12 at 9:43
11
$\begingroup$

External BUGS variants are the standard. Working within R may be convenient, but I'd be surprised if those packages are as mature and perform as well. Using a library which bridges R and the external program is usually the most common compromise.

I use the jags/rjags combo (jags might be roughly considered a dialect of bugs). I haven't tried the other bugs variants, but the reports I've heard are that jags's performance and ability to deal with numerical issues is a bit better than the other bugs variants. I find jags easy to use, but of course, you need some knowledge of bayesian data analysis to know how to use it.

$\endgroup$
  • $\begingroup$ Hmm ok thanks for you advice! So you reckon that BUGS variants are the fastest way to do bayesian analysis? $\endgroup$ – BYS2 Aug 1 '12 at 2:39
  • 4
    $\begingroup$ Yes but read a book first. Gelman's Bayesian Data Analysis is the canonical one, although Kruschke's doing bayesian data analysis has a lower barrier to entry (although perhaps not as low as the puppies on the covers suggest). $\endgroup$ – user4733 Aug 2 '12 at 0:58
7
$\begingroup$

Within the 3 BUGS variants (openBUGS/winBUGS, jags) jags seems to be the most promissing as for the future feature development, and openBUGS/winBUGS seem to be dead projects. However, jags is still lacking some niceties present in openBUGS/winBUGS (also look here). On the other hand, jags has removed some limitations present in WinBUGS, e.g.:

x ~ dnorm(0, tau) 
tau ~ dgamma(1.0E-3, 1.0E-3) # in WinBUGS, you cannot do this, 1.0E-3 is too small 
                             # for dgamma (use e.g. dgamma(0.01, 0.01))

The good news is that with most models, you can run them in all the 3 tools with just minimal changes, so you can switch to different tool later without much problems (that's what I do).

However, for some reasons (e.g. lack of parallelism and interpreter nature), it is not true that these BUGS variants are fastest way to do bayesian analysis! In fact, quite the opposite. BUGS projects are good to test and develop complicated models on small datasets. Once you have the model developed, and need to run it repeatedly on large datasets, it is more efficient to use different tools.

For example the CppBugs / rcpp combo is said to be 5-10x faster than BUGS variants. The principle is that you basically compile your model into a C++ program, which runs much faster. Also have a look at Dirk Eddelbuettel's blog for Rcpp test - looks brutally fast. You can also play with parallelism.

You can also do parallel computation in WinBUGS using bugsparallel.

$\endgroup$
  • $\begingroup$ Oh wow, ok thanks for all your advice, it was very useful :) $\endgroup$ – BYS2 Aug 15 '12 at 12:21
  • $\begingroup$ You are welcome. What is your research area? If it's ecology, I can recommend books on Bayesian analysis using WinBUGS in Population Ecology. $\endgroup$ – Curious Aug 15 '12 at 12:35
  • $\begingroup$ interesting, are there references on how cppbugs compares to jags? Since jags is written in C++, it's not immediately obvious how much overhead the interpretation layer would entail. $\endgroup$ – user4733 Aug 15 '12 at 15:12
  • 2
    $\begingroup$ Andrew gelman have a promising project called Stan (mc-stan.org) which basically is a bugs dialect that compiles down to c++ and that seems really fast compared to bugs. $\endgroup$ – Rasmus Bååth Sep 10 '12 at 13:23
  • 2
    $\begingroup$ @RasmusBååth You should make that its own answer. Stan is likely to become the piece of software for Bayesian models. $\endgroup$ – Ari B. Friedman Sep 22 '12 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.