Wednesday, February 6, 2013

Installing JAGS and rjags on Ubuntu 12.04

I ran into a few issues earlier trying to install JAGS/rjags on Ubuntu. This set of instructions assumes you already have R installed on your system

  • Download and Install R (32/64) -bit
  • Download the Bayesian Sampling Program JAGS from here : Extract the contents of the tar file and install the JAGS program by running the following commands from the JAGS root folder.
  • Download and install the rjags package : I tried install.packages('rjags') in R, which failed initially on my system (Ubuntu). Now, this may work if you're on a Mac or Windows. If you experience the same problems, you need to download the appropriate rjags tar file and and then install it manually.
  • The second line configures rjags for (32/64) bit R. If you are running 32-bit R be sure to replace \lib{64} with \lib and for 64-bit R replace \lib{64} with \lib64. This is very important as you could lose a few nights of sleep here trying to figure out why you can't link the rjags library with the JAGS program. This comes courtesy of Rrasch
    JAGS is a program that is used for the analysis of Bayesian Hierarchical Models using MCMC (Markov Chain Monte Carlo) Simulations. I used JAGS over BUGS(WinBUGS/OpenBUGS) because it is cross platform, runs on Linux and it appears to be more robust among other reasons.


  1. Hi, I am not used to dealing with linux nor programing, may be someone could give me a hint here... I am trying to install JAGS on "ubuntu, precise", I have dowloaded the file jags_3.1.0.orig.tar.gz from but I don know what to do next...where am I supposed to run the commands "./configure; make; make install"? I tried on the terminal but nothing happens...
    thanks in advance!

  2. You should run those commands in the same directory as the uncompressed JAGS file

  3. Hi, sorry bother you but I am getting a weird error and I am stuck

    Running your command last command

    sudo R CMD INSTALL --configure-args='--with-jags-include=/usr/local/include/JAGS --with-jags-lib=/usr/local/lib --enable-rpath' rjags_3-4.tar.gz

    I am getting this error

    Error : .onLoad failed in loadNamespace() for 'rjags', details:
    call: dyn.load(file)
    error: unable to load shared object '/usr/local/lib/JAGS/modules-3/': cannot open shared object file: No such file or directory
    Error: loading failed
    Execution halted
    ERROR: loading failed

    I checked is indeed in /usr/local/lib so I cannot go on installing rjags

    Any help?