Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Sunday, June 06, 2010

General steps to compile JAGS in a Linux based OS system and install rjags in R

I have an entry here about how to install JAGS and rjags in Fedora.  However, I have exchanged emails with Robert Dorazio and Dr. Martyn Plummer.  Here are the easier steps to compile JAGS and install rjags in R.

1. After you extract the source code of JAGS, go to the folder where the JAGS makefile is using a terminal.
cd JAGS-2.1.0

2. In a terminal, type the following
sudo ./configure --prefix=/usr
sudo make
sudo make install

3. The step 2 will help your system to identify where the JAGS is.  So in R, you can simply install rjags as:
install.package("rjags")

Of course, once you can install rjags successfully in R, you can install our R2jags package as well:
install.package("R2jags")

JAGS, rjags, and coda packages for Fedora

Christopher has the RPMs (for Fedora users) for JAGS, coda, and rjags on his blog. The specific blog entry is here:


If you have trouble installing JAGS or rjags in Fedora, this is going to simplify the installation process.

Friday, January 23, 2009

Install JAGS and rjags in Fedora

JAGS was developed to help those non-Window users to be able to use BUGS. However, I found it is very hard to install JAGS and its R package-rjags. Here is my note on how to install JAGS and rjags in Fedora 10. The note here should work for all Linux systems.

Compile JAGS

1. Download JAGS source code from JAGS website into any folder. The file you are looking for should look like this JAGS-1.0.3.tar.gz. The version number which might be changed if JAGS is updated.

2. Extract the tar.gz file as: tar xfvz JAGS-1.0.3.tar.gz. This will create a JAGS-1.0.3 folder that contains JAGS files.

3. Go to JAGS folder as: cd JAGS-1.0.3.

4. Do the following to install JAGS:

sudo ./configure
sudo make
sudo make install

sudo is just a Linux command that force to execute command as the administrator

5. Type jags in the terminal console to see if JAGS is installed properly. Quite JAGS by typing exit.

Install rjags

1. In the terminal console, start R as:

sudo R


2. Install rjags. In the R console, type:

install.packages("rjags", configure.args="--with-jags-include=/usr/local/include/JAGS --with-jags-lib=/usr/local/lib/JAGS --with-jags-modules=/usr/local/lib/JAGS/modules")


In each --with above, there is an empty space to separate the code.

The trick here is that rjags will ask for JAGS HEADER file, libraries and modules. So if the above code does not work, search for them and specify the right PATH in the above code.

We have also written a package called R2jags that emulates what R2WinBUGS does. But it depends on rjags. So if you have successfully installed rjags, you might want to try R2jags. It has a powerful feature which is imported from rjags that you can pick up your previous saved MCMC and update it. I have a blog entry that discuss about this feature here.