A Bayesian Information Criterion for Singular Models

On Wednesday, Mathias Drton and I will be presenting a read paper on Bayesian model choice for singular models at the Royal Statistical Society in London. You can read more about it on the RSS web site , where you can also download a preprint. The paper is scheduled to appear, with the discussion, in Series B of the Journal of the Royal Statistical Society next year.

The CRAN package sBIC by Luca Weihs implements the ideas in the paper and includes a series of vignettes that allow you to step through some of the examples in the paper.


You can always make it faster…

… but sometimes you just need a good example to show you how. Saana Isojunno from the University of Saint Andrews wrote to me with an example that stopped working when she upgraded from JAGS 3.4.0 to JAGS 4.2.0. Saana’s model showed the classic signs of a memory leak. Compilation was very slow and memory consumption increased until all available RAM was used and the process was killed by the operating system. Continue reading

New Windows binary for R 3.3.0

Updated 22 June 2016

One of the important changes in this release 3.3.0 of R is the use of a new toolchain for  Windows. Unfortunately, for packages written in C++, the new toolchain is incompatible with the old one. So I had to build a new version of JAGS for use with R 3.3.0 and above.

When you upgrade to R 3.3.0 or higher you will need to remove the current installed version of JAGS (using the Control Panel) and run the  JAGS-4.2.0-Rtools33.exe installer. Then you will be able to install the binary rjags package from CRAN.

If you continue to use R 3.2.5 or earlier then you should not use the new installer but should continue to use  JAGS-4.2.0.exe.

Q: Why is this important?

A: If you install a version of JAGS that does not match your R installation then the rjags package will spontaneously crash.

Q: Why is this happening?

A: The Rtools compiler creates binaries that are statically linked to the C++ runtime. This is good because it means that R does not need to ship with a dynamic link library (DLL) for the C++ runtime (avoiding DLL Hell). It is harmless for the vast majority of R packages that are completely self contained. However, it is a problem for packages that need to interface to an external C++ DLL. Both the R package (e.g. rjags) and the external DLL (e.g. JAGS) must be compiled with the same compiler.

Q: This is a bit awkward isn’t it?

Yes it is awkward for JAGS users. However, in terms of the management of R packages this is a minority issue. As far as I know, the only other R packages affected are the ones that interface to SYMPHONY, gdal, and QuantLib.


Generalized additive models with jagam


Simon N. Wood has arXived a paper on  Just Another Gibbs Additive Modeller: Interfacing JAGS and mgcv. Simon is the author of the mgcv package for R, which provides functions for generalized additive (mixed) modelling and is distributed with base R as a recommended package.

Since R version 3.2.0, the mgcv package has included the jagam() function, which generates BUGS code and data for generalized additive models. The  jagam() function uses the same interface as the other functions in the mgcv package. The output of jagam can be analyzed directly by JAGS, or modified and incorporated into a larger Bayesian model. We are using jagam in a couple of projects and I highly recommend it if you want to include some smoothing in a hierarchical model.

Grid shading by simulated annealing (or what I did on my holidays)

The UK spy agency GCHQ is often in the news for the wrong reasons and has recently been on something of a charm offensive to improve its tarnished image. This campaign includes stencilling job adverts on the pavement in the trendy Shoreditch area of London  and, more recently, setting a series of incredibly difficult puzzles for the general public to solve. GCHQ director Robert Hannigan included a grid shading puzzle in his Christmas cards that received wide attention in the UK press. Continue reading

JAGS 4.1.0 is released

JAGS 4.1.0 was released at the weekend. The project page on Sourceforge has download links for the source, as well as binaries for Windows and Mac OS X.

This is a bug fix release. The main purpose was to fix some of the issues that arose in JAGS 4.0.0. Among these was a spurious warning about unused variables which confused a lot of people using the command line interface (This did not affect the R interfaces). Further improvements been made to the error messages about undefined variables and directed cycles. I have to thank users of the JAGS forums on Sourceforge for bringing problems to my attention.

So what’s next? I plan to continue working on the 4.x.y series for some time and my three priorities are

  1. Documentation
  2. Finalizing the glm module (and loading it by default)
  3. Optimization

So I will be pushing further releases as and when I reach milestones for these goals.