Saturday, January 28, 2012

Complete steps for installing software and programs

November 29, 2014:
For how to get the software, please see the book's web site here (


AndrewAcosta said...

I found the book to be an excellent way to get beyond the pages of proofs and theory, to explain Bayes in terms that can easily be related to!

I have a stack of Bayesian books I am citing for my PhD dissertation, and this one sits on the top (which is often unstable since it is larger than Zellner or Albert).

Now, I want to work through every R example, and learn what JAGS can do, which is not actually in my book.

isomorphisms said...

linux boxes may experience the same problem as Macs (which you described in step #2).

For me, using Ubuntu 10.04, it was necessary to use JAGS 2.*. Downloaded the binary from JAGS site, sudo dpkg -i ****.deb, and then a further step was necessary; gksudo synaptic and fix the broken package, because

jags depends on libatlas3gf-base; however:
Package libatlas3gf-base is not installed.

Luckily Synaptic took care of the problem.

isomorphisms said...

Thank you for posting these instructions. And thanks for all your other very accessible work on Bayesian stats!

Eric Brown said...

I was able to get rjags and JAGS 3 to work on Mac OS X Lion, provided that I compiled JAGS from source. I think that it is necessary to use PIC flags when compiling JAGS so that it works with R (e.g., from MacPorts):

Install R with:
port install R +gcc46 +recommended

Install JAGS from source:
export CC=gcc-mp-4.6 CFLAGS="-fPIC -O2 -g" CXX=g++-mp-4.6 CXXFLAGS="-fPIC -O2 -g" F77=gfortran-mp-4.6 FFLAGS="-fPIC -O2 -g" ./configure --with-pic --prefix=/opt/JAGS-3.2.0

(change prefix to wherever you want to install) and then in my .bashrc

export PATH=/opt/JAGS-3.2.0/bin:{$PATH}

Close terminal window, open new window so that .bashrc is sourced. Then you should be able to install rjags with

install.packages('rjags', type='source', dependencies=c('Depends','Suggests'))

Can Candan said...

Can not install rjags

Is there an up to date information on how to install.

I'm using osx 10.9.2
r version 3.1

Tried the instructions of the above comment.

Warning: namespace ‘rjags’ is not available and has been replaced
by .GlobalEnv when processing object ‘LINE’
** testing if installed package can be loaded
Error : .onLoad failed in loadNamespace() for 'rjags', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.1/Resources/library/rjags/libs/':
dlopen(/Library/Frameworks/R.framework/Versions/3.1/Resources/library/rjags/libs/, 10): Symbol not found: __ZN5RangeC1ERKNSt3__16vectorIiNS0_9allocatorIiEEEES6_
Referenced from: /Library/Frameworks/R.framework/Versions/3.1/Resources/library/rjags/libs/
Expected in: flat namespace
in /Library/Frameworks/R.framework/Versions/3.1/Resources/library/rjags/libs/
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library/rjags’
Warning in install.packages :
installation of package ‘rjags’ had non-zero exit status

John K. Kruschke said...

Dear Can Candan:

Did you see in Step 1: "Mac users: As of May 07, 2014, it seems that rjags (step 4 below) only works for the Snow Leopard build of R3.1.0, not the Mavericks build of R3.1.0. So, use the Snow Leopard build."

I am told that if you use the Snow Leopard build of R, then the ordinary install.packages(rjags) command should work.

Please let me know if you've tried that and it does not work (and do provide details). I will forward your question to the JAGS blog (Martyn Plummer), as I do not use a Mac myself.

John K. Kruschke said...

At the JAGS discussion/help thread (here), Martyn Plummer said: "I have been in contact with Bill [NorthCott]. It will be June before he is able to make a Mavericks build, I'm afraid, so you will need to be patient. The Snow Leopard build does work on Mavericks so you will need to use this workaround until then. Sorry for the inconvenience."

Can Candan said...

Thanks Mr John,
it works as you have said :)

Jeremy Bray said...

Hi, I am running R Studio on Mac OSX Version 10.9.3 to input the programmes and do the exercises in the textbook.

When running programmes, R Studio is having trouble sourcing the 'embedded' programmes, such as plotPost.R, which is used in chapter 7, as well as openGraph.R and saveGraph.R. I just get error messages, rather than have them working.

I have followed the instructions to 'point' the default working directory to the folder where these programmes are stored, but I still can't get them to work.

Grateful for somebody giving me an idea of what I've done wrong, and how I can rectify the problem.

And many thanks for the book! What a great, comprehensible and comprehensive intro to Bayesian Data Analysis!

John K. Kruschke said...

Dear Jeremy:

The easiest way to get RStudio (or R) to use the proper working directory is to open RStudio via the file itself. That is, start with RStudio closed, then find the file (i.e., script or program) you want to open. Double-click (or equivalent in MacOS) and open the file in RStudio. When RStudio opens, it knows to use the file's folder as the working directory.

For more details, check out this video:
at 4:00 minutes and 5:30 minutes.

The above assumes that you have left all the programs together in the same folder. It also assumes that you have unzipped (a.k.a. extracted) the folder after you downloaded it.

Let me know how it goes, and thanks for your interest in the book!