Our new R package: R2jags

I have got emails occasionally from JAGS users, asking about our new R package: R2jags. Basically, R2jags runs JAGS via R and makes postanalysis easier to be done in R. Taking advantage of the functions provided by JAGS, rjags and R2WinBUGS, R2jags allows users to run BUGS in the same way as they would do it in R2WinBUGS. Nonetheless, R2jags has some powerful features that facilitate the BUGS model fitting:

  1. If your model does not converge, update it. If you used to be a R2WinBUGS user, you must feel frustrated that your model does not converge. The best thing you can do is to use your current states of parameters as the starting values for the next MCMC. On the other hand, in R2jags, you just type in the R console:

    fit <- update(fit) 
    

    This will update the model.

  2. If you have to shutdown your machine but the model is still not converged.... In R2jags, you can go ahead and save the R workspace and shutdown your machine. When you are ready to run the model again, load the workspace in R and type:

    recompile(fit)
    fit.upd <- update(fit)
    

    This will recompile the model, which means you can update the model again!!

If you want to explore more features of the R2jags, just type ?jags in the R console. The example code contains all the functions in the R2jags.

Installing JAGS and rjags can be tricky in the Mac OS or in the Linux system. I have a blog entry here that shows how this can be done. If you are not a Window user, this post might help you.

2 thoughts on “Our new R package: R2jags

  1. Thanks for developing this package – it's a great resource! I was hoping eventually the inits=NULL option will be turned on too – I think the current version only takes numerical values.

Comments are closed.