|
I've previously posted on compatibility issues encountered when
installing R and JAGS on
Macs
or
Ubuntu
, but
Windows seemed immune to these problems ... until now!
The
issue arises because current R versions, 3.3.0 or later, are not
compatible with the current default installer for JAGS. Note
that the problem is with the Windows
installer
, not JAGS
source code, and doesn't affect other platforms. A compatible
installer is available, but it's not the default. See
Martyn Plummer's post
for more details.
Install R
Download and install
R statistical software
from the CRAN web site.
Install JAGS
If you already have JAGS 4.2.0 installed, it's a good idea to
uninstall the old JAGS 4.2.0 using Control Panel > Programs and
features (Windows 7) or Settings > System > Apps & features
(Windows 8, 10) and delete the old JAGS 4.2.0 folder in Program
Files before installing the new binaries.
Download and run the new installer, "
JAGS-4.2.0-Rtools33.exe
".
This is not the default on Sourceforge, so make sure you get the
right file - you may have to search a bit. The default
installer, "JAGS-4.2.0.exe", is
not
compatible with R
3.3.0 or later.
Install the
rjags
package
After installing R and JAGS, install
rjags
by
opening R and typing
install.packages("rjags")
Boxes may pop up asking about personal libraries: click Yes. You
will need to select a mirror web site near you, or choose
0-cloud, which is a world-wide network.
Once installed, check that it works by running
library(rjags)
You should see a message telling you that
rjags
has linked to JAGS 4.2.0.
Background
Starting with R version 3.3.0, a newer compiler is used to
create the code actually used by the Windows operating system,
the "binaries", the files you get when you download and run
"R-3.3.x-win.exe". Specifically it uses the gcc 4.9.3 compiler
for C and C++ code instead of gcc 4.6.3. Some packages contain C
or C++ code, and they need to be compiled with the same compiler
that was used for R. For packages on CRAN, this is taken care of
automatically: when you run
install.packages()
or
update.packages()
, you get the package binaries
that match your R version.
This applies to the
rjags
package too, it has to
match the R version. But it also has to match with JAGS. JAGS
source code is also in C++, and running the "JAGS-4.2.0.exe"
installer gives you binaries from the
old
compiler.
Binaries created with the new compiler are in
"JAGS-4.2.0-Rtools33.exe".
If you are just using JAGS from the command line, not from R,
none of this matters.
I have actually (inadvertently!) thoroughly tested R 3.3.0
with the old JAGS binaries on 64-bit installations and had no
problems. But when I installed R 3.3.0 on a 32-bit machine
together with the old JAGS binaries, calling
library(rjags)
caused R to crash: "R for Windows GUI front-end has stopped
working."
|