reduce size of an MCMC/ rjags object I have recently started running more complicated Bayesian models in R using the rjags package. As model complexity has increased I have had to run longer chains to reach convergence for some parameters. Generally I will try a run at 20,000 and if this does not converge, use the update function to increase the chain length.
For simple models I can save the model object, and it is small enough to share easily (<50 Mb), however I have a few models that require chains around 800,000 in length to reach convergence which result in objects >100 Mb.
Is there a function or technique to reduce the size of these objects before I save them? I am familiar with the concept of thinning when starting the model, but am interested if there is a technique to "thin" the chains post-hoc.  
 A: Three thoughts:

*

*That many samples until convergence sounds like there are issues with your model/priors. The diagnosis would require seeing the model -- and also more knowledge than I have. Some models are just hard, sometimes you can use tricks that make them more amenable, and sometimes you have an outright error.


*Most MCMC samplers have a thin=n argument that says to only save every nth sample. I couldn't find it for rjags but I assume JAGS supports an option like that.


*You might consider switching to rstan (directly, or via rstanarm or brms). Each iteration takes longer, but in general each iteration is less-correlated and of better quality, so it's not unusual to use 3-5K iterations rather than tens-of-thousands. (In particular, Stan is better at ridge-like distributions than other samplers. As an example of someone who switched to Stan and saw a huge improvement: Managing high autocorrelation in MCMC)
The difference between Stan and JAGS is that JAGS (like BUGS) is a language to describe a model, while Stan is more executable. For example, a JAGS for is not an actual loop, but rather a plate specification, while in Stan a for actually is a for loop.
