I was trying to figure out how to install different JAGS/rjags versions locally to compare them (and because I had to do it on a cluster) and I'm not sure if I've found the right way to do this. My question is: is this the way to go for multiple versions of JAGS/rjags on one system? Is it possible to just use one rjags version? The idea would be to keep one JAGS compiled for speed and one for debugging.
As far as I know you need to install them in pairs since rjags is linked to a specific JAGS version so you can't just pass some argument to library() to use one rjags with multiple JAGS versions. I use $HOME throughout to refer to the local directory. Martyn's installation manual describes these steps piece by piece.
Installing JAGS locally (straight from the manual...) After unzipping/changing directory to JAGS I do:
./configure --prefix=$JAGS_HOME --with-blas="-lrefblas" \
make && make install
The --with-blas and --with-lapack were necessary on my system but they are often not. In my case .configure gave errors about not finding sgemm/cheev in the default blas/lapack so I switched to the reference libraries. Then the jags executable ends up in $HOME/JAGS/JAGS-1/bin, the libs are in $HOME/JAGS/JAGS-1/lib, and so on.
Then installing rjags:
When installing rjags from an R terminal, you can specify a local JAGS
library to link to as, and specify a 'lib.loc' which is where rjags
will live. I assume here and in run_jags.R that this is "~/R/library/rjags-1"
If you get errors about finding specific files... check your --with-jags-* paths, they're likely a little wrong. Then I could load this particular JAGS/rjags combo with:
Then it's just lather-rinse-repeat for however many versions of JAGS I want to look at. Is there a better way to do this? It would be much neater to be able to use one rjags version but... I'm not sure it's possible.
Oops, the 'install.packages' call needs --enable-rpath or the system JAGS executable is linked... not sure why yet...
Because the JAGS library is not on the default linker path so will not be found by the linker. Using the --enable-rpath option hard-codes the location of the library into the rjags package when it is compiled. Alternatively, you could set LD_LIBRARY_PATH to include the directory that contains the JAGS library (/home/krzysiek/JAGS/JAGS-1/lib) at runtime (including when you install the rjags package, as R will try to load it after installation).
That makes sense, thank you. I got confused by the JAGS (not rjags!) manual and I didn't think to go look in the rjags README (where this is all thoroughly explained). Sorry!