suyusung / R2jags

R2jags: Using R to Run 'JAGS'
8 stars 3 forks source link

Crucial fix of bug in jags.R function + rename pD to pV #21

Closed giabaio closed 2 months ago

giabaio commented 2 months ago

I think I found a crucial bug in jags.R; after creating the JAGS object (via jags.model), the current code proceeds to an adaptation phase (via rjags::adapt). But this doesn't store the simulations and so, effectively, there is no burnin considered in a R2jags run. For some models this is a problem because the resulting simulations are not at convergence and so they show massive variance in the node deviance (with typically a handful of outlier, with very large values). Other monitored notes may also show this artificial problem.

Also, I have renamed the variable pD to pV, because that's effectively what it is, in the JAGS computation (= var(deviance)/2). I have also added the possibility of computing the "proper" pD, via a call to rjags::dic.samples() and then modified the print method.

I have done some tests and, for the model that was showing problems, now R2jags works and give the correct results. The table and objects generated by jags.R are OK with the change in notation for pD/pV.