From Documentation
Revision as of 12:42, 10 December 2014 by Bge (Talk | contribs) (Created page with "==Obtaining OpenBUGS== OpenBUGS is an open source project. It can be downloaded from [http://www.openbugs.net/w/FrontPage here]. Look for the package for Linux, it comes as g...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Obtaining OpenBUGS

OpenBUGS is an open source project. It can be downloaded from here. Look for the package for Linux, it comes as gzipped Unix tar file, named as OpenBUGS-version.tar.gz, e.g. OpenBUGS-3.2.3.tar.gz.

Installing OpenBUGS for Linux

First, save it and copy it to your account, say, in folder Downloads. Then unpack it with command

tar zxvf OpenBUGS-3.2.3.tar.gz

This will extract the content from the tar file and put in folder OpenBUGS-3.2.3. Then go into that folder

cd OpenBUGS

and run configuration first

./configure --prefix=$HOME/lib/openbugs-3.2.3

This sets where to install the package. In this case, it will be installed in /home/you/lib/openbugs-3.2.3. You may choose another location you like. By default the installation directory is /usr/local, which is not what you want.

Then compile and install it with commands

make
make install

The compilation shouldn't take long to complete. It is likely, however, that the compilation may fail due to missing system files. specifically, gnu/stubs-32.h. If this is the case, you will need to ask the system administrators to install the missing system files.

Upon success, you should have three folders created in /home/your/lib/openbugs-3.2.3

bin   lib   share

In bin, there are two binaries: OpenBUGS and OpenBUGSCli. OpenBUGS is what you will need when you run R calling bugs.

Installing R2OpenBUGS for R

In order to user OpenBUGS in R, you need an R interface to BUGS. The package R2OpenBUGS is recommended. The package can be installed in user space. To install it, first, load R module. You might need to unload intel module on SHARCNET systems to avoid possible conflict

module unload intel

To see what releases of R are available, use command

module avail r

If you prefer a specific version, e.g. 3.1, then use command

module load r/3.1

Otherwise, the command

module load r

would just load the latest version by default.

Then run R from command line. At the R prompt, use R command install.packages() to install R2OpenBUGS

>install.packages("R2OpenBUGS")

and follow the instructions.

Using OpenBUGS in R

The R2OpenBUGS is an interface to OpenBUGS. In order to user OpenBUGS, you need to tell where OpenBUGS resides. According to the help info, as you would get from R command

>library(R2OpenBUGS)
>... ...
>help(bugs)

there are two ways of telling bugs() where OpenBUGS is. First you may specify the path to OpenBUGS in the call to bugs() in your R code, e.g.

>schools.sim <- bugs(data, inits, parameters, OpenBUGS.pgm="/home/you/bin/OpenBUGS", model.file="/home/bge/schools.txt", n.chains = 3, n.iter = 1000, working.directory = NULL)

Or, you may simply set environment variable at the command line or put the following line in .bash_profile in your home directory.

export OpenBUGS_PATH=$HOME/bin/OpenBUGS

In both cases above, it is assumed that OpenBUGS executable is installed in /home/you/bin.