Issues with the runjags package

Back to home page The wiqid package for R uses functions in the runjags package. This sometimes has problems, a couple of which are covered here:

JAGS was not found in the common install locations on your system... or Unable to call JAGS...

Find the file jags-terminal.exe on your computer. On Windows, likely locations are:

  • C:\Program files\JAGS\JAGS-3.4.0\x64\bin\jags-terminal.exe
  • C:\Program files\JAGS\JAGS-3.3.0\xi86\bin\jags-terminal.exe
  • C:\Users\yourName\AppData\Local\JAGS\JAGS-3.3.0\x64\bin\jags-terminal.exe

If you have a non-English version of Windows, you may have something like "Archivos de programa"  or "Programme" instead of "Program files".

After loading runjags, you can tell runjags where to find JAGS:

runjags.options("jagspath" = "/Program files/JAGS/JAGS-3.4.0/x64/bin/jags-terminal.exe")

...inserting your own path to jags-terminal.exe (with /forward/slashes/ or \\double\\back\\slashes\\) in place of the text in red.

But you have to do that each time you use runjags. If you do this often, create or modify your personal ".Rprofile" file. This is usually in your "My Documents" folder. You can find out if it exists with the following code:

profilePath <- file.path(Sys.getenv("HOME"), ".Rprofile")

This returns 0 if the file already exists, -1 if it doesn't exist. If it does exist, you can edit it with Notepad. If it does not exist, Windows will not allow you to create it, so we need to get R to help. Either way, you can use this code to create or modify .Rprofile:

zz <- file(profilePath, "a") # open a file connection for appending
writeLines(.runjags.options <- list("jagspath" = "/Program files/JAGS/JAGS-3.4.0/x64/bin/jags-terminal.exe"), zz)

...inserting your own path to jags-terminal.exe in place of the text in red.

The object .runjags.options will be created in your workspace every time you start R, and runjags will use it to set its options when you load the package.

Updated 19 Dec 2014 by Mike Meredith