You have specified 10000 samples with a thin of 2, which means that JAGS is only storing every second iteration, so you need 20000 iterations to get 10000 samples, which is what happens. But if you look at the number of iterations stored (per chain) it should be 10000. As far as I can see this is the case e.g.:
library('coda')library('runjags')X<-1:100Y<-rnorm(length(X),2*X+10,1)model<-"model { for(i in 1 : length(Y)){ Y[i] ~ dnorm(true.y[i], precision); true.y[i] <- (m * X[i]) + c} m ~ dunif(-1000,1000)c ~ dunif(-1000,1000) precision ~ dexp(1)#data# Y, X#monitor# m, c, precision}"(nc<-sample(1:4,1))(sa<-sample(1:5,1)*1000)(th<-sample(1:5,1))results<-run.jags(model=model,n.chains=nc,sample=sa,thin=th,method="rjags")#Theseshouldmatch:cat('... ',sa*nc,' samples (thin = ',th,'; chains = ',nc,'; ...\n',sep='')results#ConverttoMCMCobject:mcmc<-as.mcmc.list(results)#Reportstheexpectedsamples,chainsandthin:summary(mcmc)#Totalsamplesisasexpected:stopifnot(niter(mcmc)==sa)
If you find a combination of parameters that doesn't work, could you post a reproducible example?
Matt
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks, Mr. Denwood. I just misunderstood the way the function works. I thought it would sample 10000, thinning by 2 along the way, to keep a remaining 5000.
Matt
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi.
My version of run.jags seems to run 20000 iterations regardsless of what I specify in the "samples" statement.
Any idea what I'm doing wrong?
Many thanks,
Matt
You have specified 10000 samples with a thin of 2, which means that JAGS is only storing every second iteration, so you need 20000 iterations to get 10000 samples, which is what happens. But if you look at the number of iterations stored (per chain) it should be 10000. As far as I can see this is the case e.g.:
If you find a combination of parameters that doesn't work, could you post a reproducible example?
Matt
Thanks, Mr. Denwood. I just misunderstood the way the function works. I thought it would sample 10000, thinning by 2 along the way, to keep a remaining 5000.
Matt