Solved – Thinning chains in BUGS/JAGS

bayesianbugsjagsmarkov-chain-montecarlowinbugs

Hi I have a quick question about the details of running a model in JAGS and BUGS.

Say I run a model with n.burnin=5000, n.iter=5000 and thin=2. Does this mean that the program will

  • run 5,000 iterations, and discard results,

and then

  • run another 10,000 iterations, only keeping every second result?

If I save these simulations as a CODA object, are all 10,000 saved, or only the thinned 5,000? I'm just trying to understand which set of iterations are used to make the ACF plot?

Thank you

Best Answer

Short answer: The number of iterations incorporates the burn in and does not incorporate thinning.

Less short answer: If you were to run a BUGS model through R2WinBUGS or R2OpenBUGS (or view a summary of WinBUGS output) with the arguments you stated:

 n.iter=5000, n.burnin=5000, n.thin=2

you would get an error message/no output. n.iter refers to the total number of iterations including the burn in, hence all your iterations are burn in and are thrown away (or not included in the CODA output and any ACF plot in WinBUGS).

Thinning is treated differently (in relation to n.iter). For example if you set your MCMC up with any of the following arguments:

 n.iter=6000, n.burnin=5000, n.thin=1
 n.iter=6000, n.burnin=5000, n.thin=5
 n.iter=6000, n.burnin=5000, n.thin=10

only 1000 iterations will be saved, i.e. all non-thinned simulations are discarded (in CODA output or any ACF plot in WinBUGS).

Not sure if this is the same for jags?