-
Notifications
You must be signed in to change notification settings - Fork 2
2 Overview of MCMC Using R2Jags
SOLV-Code edited this page Jan 10, 2025
·
5 revisions
Just a place to park some initial notes for now
WinBUGS resets to a fixed random seed every time you run it (regardless of the random seed you set in R), whereas OpenBUGS and JAGS use a random (different?) random seed every time. Therefore:
- two people running a WinBUGS MCMC with the same settings will get the same result on 2 different computers (and you'll get the exact same result every time you run it). This may give you a false sense of stability.
- OpenBUGS and JAGS will give you different results every time you run it, so re-doing the model run a few times and comparing the results is a good way of checking the stability of estimates.
R2WinBUGS and R2JAGS handle thinning the same way, but R2OpenBUGS does the opposite! R2WINBUGS & R2JAGS: do n.burnin and n.samples, then thins based on n.thin, so that n.sample/n.thin mcmc samples are stored R2 OpenBUGS: does n.burninn.thin and n.samplesn.thin, then stores n.samples mcmc samples
Even if you adjust settings accordingly, there are still small differences:
- R2WinBUGS rounds up when calculating n.iter/n.thin, then drops some of the final samples for some unknown reason
- R2OpenBUGS rounds up when calculating n.iter/n.thin
- R2JAGS behaves exactly like R2OpenBUGS after the above correction
So, for settings.in = list(n.chains=2, n.burnin=20000, n.thin=60,n.samples=50000)
- R2OpenBUGS and R2JAGS each do 333 burnin (after thinning) plus 500 samples (after burnin), and spits out 1000 MCMC samples (500 * 2 chains)
- R2WinBUGS does 334 burnin (after thinning) plus 500 samples (after burnin), but spits out only 812 MCMC samples from the 2 chains. I have not been able to fix that last inconsistency, and have decided to call it a low priority...