I have been using JAGS but I am not quite sure how it actually simulates it values. I need to know in a general sense what's going on in the background.


2 Answers 2


There are several tools used by JAGS and/or BUGS.

Where conjugate distributions are used, straight Gibbs sampling is done. When that's not the case, adaptive rejection, slice sampling, or Metropolis-Hastings might be used (this is the case with BUGS at least; I believe it would be the case for JAGS as well).

You can examine the source code yourself and see exactly what it's doing in various circumstances. Also check out the discussion and the wiki.

Martyn Plummer's jags blog also has useful information: http://martynplummer.wordpress.com/

  • $\begingroup$ I followed the links but could find nothing that answered the OP's question. $\endgroup$ Commented Jun 5, 2014 at 6:52
  • 1
    $\begingroup$ @Dominic The OP's question is "what's going on in the background". One of the major statistical tools JAGS uses is mentioned in the first paragraph of my answer (and it's really only the statistical aspect that's on topic). Examining the source code (navigating from the page at the second link to here for the actual 1.6 Mb tarball) which shows exactly what's going on. I'm mystified what more you could want, but you're certainly free to post a new question that details what you want to find out. $\endgroup$
    – Glen_b
    Commented Jun 5, 2014 at 8:15
  • $\begingroup$ I probably misinterpreted the question but I thought the OP was asking about the G for Gibbs in JAGS [otherwise wouldn't it be called JASS - Just Another Slice Sampler :-)] and I am probably being fussy but I think one should have a specification other than the source code. This looks more apposite (to me at any rate): puma.isti.cnr.it/dfdownloadnew.php?ident=/cnr.isti/…. $\endgroup$ Commented Jun 5, 2014 at 8:37
  • $\begingroup$ Dominic: If you believe you have a better answer, could you post it? $\endgroup$
    – Glen_b
    Commented Jun 5, 2014 at 8:45
  • $\begingroup$ I accept your challenge :-) but as you say the question is somewhat vague. The question I will answer is why Gibbs sampling works and I will give a few examples using Haskell, JAGS and STAN. Of course without understanding the internals of JAGS which you point out it perfectly possible given enough time, one cannot really say what it is actually doing. In terms of understanding what is going on, I feel one is on firmer ground with STAN as it uses Hamiltonian Monte Carlo. I have a feeling that JAGS knows about conjugate distributions and uses slice sampling if they are not available. $\endgroup$ Commented Jun 12, 2014 at 8:31

According to the JAGS documentation,

A report on the samplers chosen by the model, and the stochastic nodes they act on, can be generated using the “SAMPLERS TO” command.

It seems that the user can't control the choice of sampler, which is automatically chosen by JAGS, as described in the manual. I'd say that typically, it will choose a slice sampler. Again, to quote the documentation,

Slice sampling [Neal, 2003] is the “work horse” sampling method in JAGS.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.