Our JAGS preferences 

HOME 
At the start of the recent "Bayes with JAGS" workshop, we wrote
down some ideas to try to make the code we give to participants
more consistent: a sort of style guide for JAGS. Once you stop
writing WinBUGScompatible code, lot of options open up. A key point is that JAGS can use vectors and matrices (WinBUGS can't) which makes your code run faster. = We want to use the nice features of JAGS, we don't care if our models won't run with WinBUGS or OpenBUGS.  JAGS works with vectors and matrices. So if Either way is easier than JAGS runs faster with matrices or vectors! The models I tried gave time savings up to 50%. Click here to download a ZIP file with example code.  JAGS allows you to do arithmetic inside the parentheses of
functions and distributions. A common case in occupancy models
is  The same applies to square brackets for indexing. Suppose
you have a 0/1 parameter for  JAGS has a length function for vectors, which you can use
for looping: = We prefer the extension .jags for JAGS model files instead of .txt.  Then no need to include 'model' in the file name, and if you sort files by type in File Manager, all the model files will be grouped together.  We can add .jags to the file extensions in Notepad++ and get Rstyle syntax highlighting. = We prefer to put the likelihood before the priors in the model. This is generally the way we build up models, and here we agree with John Kruschke. Though we like to build the biological model first with what Link & Barker (2010) call "the data we wish we had", and then do the observation model with the actual data. = We prefer It's then clear that we are dealing with a probability and it's easily adapted for informative priors. And it runs slightly faster in JAGS. = We prefer to put priors on biologically meaningful things.  For example:  We like Marc Kéry's prior for the intercept of a logistic
model:  We don't like commonlyused priors which are biological nonsense, such as Gamma(0.001, 0.001). Sensible Gamma priors are ok. (And in the last case we are in agreement with Andy Gelman and the Stan gang.) = We prefer meaningful names for things instead of letters. For example: = We don't use 'superpopulation' to refer to the augmented population when using data augmentation. 'Superpopulation' has a specific meaning in CrosbieManlySchwarzArneson (CMSA) open population models and using the same term invites confusion. Just wait until you want to run a CMSA model with an augmented superpopulation! = We prefer For occupancy modelling, we use = We like Bill Link's prior for omega. Back in 2013, I did thousands of simulations of SECR analyses with small populations; I encountered a few cases where augmentation was not sufficient no matter how big I made M, and population estimates got more and more ridiculous as I increased M. Then came Bill Link's (2013) paper explaining the problem: there's no guarantee that the usual discrete uniform prior will converge. So I prefer his = We don't like It's what we see every day in R! Not part of the JAGS model definition, but related to it: = We don't supply unnecessary initial values. If no initial values are supplied for a parameter, JAGS draws
random values from the corresponding prior. If the prior is something like Though if you want to avoid the chains starting near zero or
near 20, you could have Sometimes random values don't work (we get a "node inconsistent with parents" error), and we need to provide appropriate values. 
Updated 9 March 2019 by Mike Meredith 