Some software options for Bayesian statistics on 64-bit Linux

So, you’ve been living the dream that is 64-bit Linux ownership, but you want to do Bayesian stats using the BUGS language. We’ve all been there…Okay, this is kind of niche, but here are some notes on what you can do.

The BUGS (Bayesian inference Using Gibbs Sampling) language is pretty nifty. I find that it’s a very useful way of coding statistical analyses while focusing on the statistics rather than the code. It’s comparatively easy for a statistician to read and it has a certain elegance, even if it can be a pain to get things to work.

If you want to install a BUGS-based programme, you have options, as detailed below. All of these can be run through R, which is handy for both data manipulation prior to analysis and, crucially, analysis and use of simulated results, as stored in CODA files.

Install JAGS

JAGS (Just Another Gibbs Sampler) is something I’m currently playing with. It’s a particularly useful option if you’re a bit of a biff at Linux because it’s actually stored in the Ubuntu repository. That means that there’s a good chance that you can install it using the Software Manager of the Ubuntu flavour of Linux or a related distro (e.g. Mint). Just search for JAGS.

Install WinBUGS

WinBUGS is still the most commonly cited BUGS software I come across, but I would advise against using it. Development is not ongoing, and current efforts are focused, quite sensibly, on OpenBUGS. WinBUGS is easy to install and can be run under Wine, but I have no idea why you would choose to do this for Linux.

Install OpenBUGS

This is the real reason for this post. OpenBUGS is the current main alternative to WinBUGS, but is strangely difficult to install on 64-bit Linux systems. Here’s how to do it.

First, download the current source package from the OpenBUGS site. This will be in the form of a tarball(i.e. a file named *.tar.gz).

The code below will have to be adjusted to suit whatever version of OpenBUGS you download. OpenBUGS is written for 32-bit systems and 64-bit systems will fail during the installation process. To get round this, you need an appropriate compiler. For Ubuntu and Mint, the appropriate compiler is g++-multilib. To install it, open a terminal and type:

sudo apt-get install g++-multilib

The sudo bit makes you run as a super-user (aka administrator – you should avoid running like this usually). The apt-get bit is the Advanced Packaging Tool, which is the way Linux sorts out packages and dependencies. Basically, it makes life much easier. Install does what is says on the tin, and g++-multilib is the package name. This general approach can be used to install anything in your distribution’s repositories (including JAGS, if it’s there).

Now you can just follow the OpenBUGS instructions as stated on their site. In the terminal, type:

tar zxvf OpenBUGS-3.2.3.tar.gz

Tar is a programme that can be used to manipulate tar files. A tar.gz file, often called a tarball, is a tar file compressed using gzip. Zxvf is actually a series of commands:

  • z tells tar to read or write files through gzip
  • x tells tar to extract files
  • v tells tar to be verbose. This means it tells you what it is doing. This is not, strictly, necessary. However, I find it reassuring and it can be useful for debugging
  • f tells tar to write a file

The result of this is that zxvf reads a tar.gz file using gzip, extracts it, tells you what it is doing, and writes the file as a standard (.tar) file. Magic. The reason I’m telling you this is that these shorthand commands are used a lot in Linux. There’s some reference material about the tar command here.

The unpacked file forms a new directory that you can move to using the cd, or change directory, command:

cd OpenBUGS-3.2.3

We now have the source code for OpenBUGS on our system and we are in the correct folder to use it. To actually install it is a three stage process. First, we need to configure a thing called a makefile. We are in the correct folder, so we can type:

./configure

This configures the makefile in the current folder. The “.” just tells it that the current folder is used. The make command can then be used to generate a makefile, which is installed with the install command.

make
make install

You should now have OpenBUGS installed.

Posted in Tips, tricks and notes Tagged with: , , , , ,

Leave a Reply