To use the programs, there are six basic steps:
- Install the general programming language R. Go to the R web site and install the latest version of R appropriate for your computer (Windows, Mac, Linux).
- Install the R editor RStudio. R comes with its own built-in editor, but it is not very useful for dealing with long programs. Go to the RStudio web site and install the latest version of RStudio appropriate for your computer (Windows, Mac, Linux). This is optional, but highly recommended.
- Install the Bayesian sampling program JAGS. Go to the JAGS web site and install the latest version of JAGS appropriate for your computer (Windows, Mac, Linux).
- Install the package that lets R talk to JAGS. Invoke RStudio. Click the "Tools" menu and then "Install Packages." In the Packages slot type "rjags" without the quotes, or, if a menu of packages appears, select rjags. Then click install. (Alternatively, if working in R not RStudio, at the command line, type install.packages("rjags") You may be prompted to select an internet archive to get the package from; select a site geographically near you.)
- Get the programs used in the book. For a zip file (named ProgramsDoingBayesianDataAnalysis.zip) that contains all the programs in a single file, click HERE. Be sure to unzip (extract) the programs from the zip file.
- Read the important tips for running the programs, below! Really, read them. Remember them. It'll save you frustration later.
• I now recommend using JAGS instead of BUGS, and that's why the installation instructions (above) only mention JAGS, not BUGS. Any program that had "Bugs" or "Brugs" in its file name now has a JAGS equivalent with "Jags" in its file name. More info is available at this blog post.
• Many of the programs call other programs when running, and write auxiliary files, so
• put all the programs together in the same folder (they come together in one folder, so it's easiest to leave them there),
• put that folder under a writeable directory (not in a protected system folder), such as where you would store ordinary research data, and
• be sure that R has that folder as its working directory. Set the working directory in RStudio from the menu: Tools -> Set Working Dir. Or, if you're using R's built-in editor, set the working directory in R's command console from the menu: File -> Change dir...Without setting the folder as R's working directory, you will get errors when programs try to find other files and can't find them.
• Mac or Linux users: Having trouble with graphics when running the programs? I have begun modifying the graphics commands in the programs so that the same commands work on MacOS/Linux and Windows. If you are using MacOS/Linux and encounter graphics troubles, see this blog post for info on how to modify the graphics commands.
• Programs are updated occasionally. For a list of individually downloadable programs sorted by date modified, click HERE. You can check if you have the most recent version.




