APTS Computer-Intensive Statistics 2012

Background material

Preliminary material in PDF.
Hints, in PDF.
Step-by-step solutions, in PDF.

Material for the lectures

Lecture notes in PDF — hard copies will be handed out at Warwick.

R demonstration scripts for
simulated annealing
MCMC simulation of the Strauss process, including an introduction to CODA
slice sampling.

For animations, note the comments in the files: you will need to turn anti-aliasing off, and set the graphics device up for the fastest possible response.

Material for the labs

This is all draft material

R script for Tuesday's computer lab CIS1.R
R script for Wednesday's computer lab CIS2.R
R script for Thursday's computer lab CIS3.R

All JAGS model files can be found in directory scripts.

Some of the parallel code may throw up a message from the firewall on Windows or Macs. You may not be able to grant the permissions it is asking about (they may need administrator privileges), but they are not actually needed (the firewall code fails to notice that it is connections to the same machine that are being used).


You need R 2.15.0 or later, or perhaps 2.14.x (untested). We will be using the R packages LearnBayes, MCMCpack and rjags, which depend on package coda. Package rjags also requires JAGS installed.

If you have the opportunity to use 64-bit R we suggest you do: the scripts may run appreciably faster.

Some of the code makes use of multiple cores on the computer for speed, and we will assume that you have at least two. It is also possible to have multiple R sessions open and run computer-intensive tasks on one or more in the background.


JAGS comes in a combined version for 32- and 64-bit Windows. So download and install JAGS-3.2.0.exe.

Then install packages LearnBayes, MCMCpack and rjags from CRAN in the usual way (which will pull in coda).

Mac OS X

Install JAGS from http://sourceforge.net/projects/mcmc-jags/files/JAGS/3.x/Mac OS X/, then install packages LearnBayes, MCMCpack and rjags from CRAN (which will pull in coda).

This should work with 32-bit or 64-bit R (and even with PowerPC Mac OS 10.5). 64-bit R is installed as R64.app and R64 at the command line (and also as R on Snow Leopard and Lion).


JAGS can be installed from the sources at http://sourceforge.net/projects/mcmc-jags/files/JAGS/3.x/. Also install packages LearnBayes, MCMCpack and rjags from CRAN (which will pull in coda).

There are Debian and Ubuntu packages for JAGS available: some of them (e.g. for Debian 'stable') are too old although 3.1.0 should be OK. You might want to try

sudo apt-get install libblas-dev liblapack-dev jags
There are also packages such as r-cran-mcmcpack, but these are often not current.

JAGS binaries for various RPM-based distributions are available here.

Packaging of the JAGS sources for Gentoo is available as an `ebuild' for x86 and amd64.

If you install JAGS from the sources on x86_64 Linux do read the installation manual: on RedHat/Fedora/SuSe systems you need to set libdir since the default is the (out-of-step-with-the-world as usual) Debian convention.

Last edited on 4 June 2012