Re: [R] R vs. Bugs

From: Paul Johnson <>
Date: Sun, 22 Jun 2008 19:47:20 -0500

Hey, good topic for a thread. I've wrestled with this over the years. I think there's some user confusion about what WinBUGS does. People who did not see BUGS before WinBUGS tend not to understand this in the same way...

The unique / important contributions from WinBUGS are the collection of working examples and the Doodle code generator thing. All of the rest of it can be easily replaced by open source tools that exist or could easily exist.

On Sun, Jun 22, 2008 at 11:34 AM, Peter Muhlberg <> wrote:
> I've done some looking around in R and elsewhere to answer my question
> on the value of R vs. Bugs for MCMC. So, for anyone who is curious,
> here's what I think I've found: Bugs compiles its code, which should
> make it much faster than a pure R program. Packages such as AMCMC run
> MCMC in R, potentially with a user-defined C function for the
> density--which should make it comparable in speed to Bugs. The
> packages MCMCpack (MCMCmetrop1R function) and mcmc seem designed to
> run w/ a density function written in R. MCMCpack does have functions
> that use precompiled C code from the Scythe library (which looks
> nice), but I see no simple way to add a C density function. AMCMC and
> Bugs seem to use adaptive MCMC, but the other R packages don't appear
> to do so, which may mean another performance reduction.

Think of "performance" as a combination of development time and run time.

Andrew Martin's MCMCpack reduces development time by giving people some pre-packaged Gibbs sampling fitters for standard models, such as logistic regression. It still uses the same iterative sampling routines "under the hood" as most other MCMC approaches. The only difference there is that it has routines formatted in a way that will be familiar to R users. I do not believe a simulation model conducted in MCMCpack will take a different amount of "run time" than a well coded, custom version of the same that is prepared in WinBUGS or any other GIBBS sampler. The big difference is that MCMCpack offers routines for familiar models, and if one wants to "thrown in" some random parameter here or there, then MCMCpack won't be able to handle it.

The U. Chicago professors provide the package bayesm which is roughly the same kind of thing. For pre-existing model types, an MCMC model can be conducted.

Students ask "Why learn BUGS when I can use MCMCpack (or bayesm)?" Answer: no reason, unless you want to propose a model that is not already coded up by the package.

> I see no way to insert my own proposal density in the R functions.
> JAG, a Java-based version of BUGS, apparently allows users to create

If you mean to refer to Martyn Plummer's project JAGS:

JAGS is "Just Another Gibbs Sampler", and it is decidedly not written in Java. It is, rather, written in C++.

JAGS is proposed as a more-or-less complete drop in replacement for BUGS, so the user can write up a BUGS style model and then hand it over to JAGS for processing, the same way we used BUGS before the WinBugs came along and tried to make it a pointy-clicky experience. JAGS has versions of the classic BUGS examples, and I think it is very well done. If you want to run a Gibbs Sampling exercise in Linux, I suggest you seriously consider using JAGS. You might use WinBUGS Doodle thingie to sketch out the code for your model, but then translate it to JAGS. (I put a bit of thought into packaging an RPM for Fedora users a few months ago, but ran into a few little packaging errors that put me off of it. Now I'm running Ubuntu and packaging for that is harder, at least for me...)

I notice there are some R packages that are providing pre-packaged estimators for common models through JAGS. Check witness:

bayescount	Bayesian analysis of count distributions with JAGS
bayesmix	Bayesian Mixture Models with JAGS

It is disappointing/frustrating to me that the source code for WinBUGS/OpenBugs is kept in secret, because here's what I'd really like.

  1. Make a version of Doodle for sketching out models. As far as I can see, Doodle is the only truly uniquely valuable component in Win/Open BUGS. It helps people get started by providing a code template.
  2. Create an avenue for that Doodle code to travel to JAGS. rJAGS exists as an interface between R and jags.
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Mon 23 Jun 2008 - 00:55:44 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 23 Jun 2008 - 01:30:52 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive