Quick post on a noteworthy R package that could be useful for bayesian models with many (hundreds or even thousands) parameters.
I am working on a Bayesian scaling technique that remedies to the problem of interpersonal comparability in ideological self-placement. The idea is simply that observed positions on a scale, such as the perceived position of political parties on the left-right continuum, can be modelled as a linear function of the latent common-scale position, through an individual shift and a stretch parameters.
The thing is that this kind of models generates a ridiculous number of parameters. If we consider a hypothetical survey with 1,000 individual interviews and five political parties to be placed, I count 2,010 parameters, including: 2,000 individual parameters (1,000 shifts and 1,000 stretch parameters), five latent positions of the parties, and five variance parameters (I am assuming normality). Also, I am not considering one country but 15, so the diagnostics’ task should be repeated again and again.
Until you find yourself facing this task, it’s hard to realise how painful it can be to check whether the Markov chains have been mixing properly with so many parameters. I had my dose of painful minutes trying to figure out a solution, but then I’ve crash into this package, is `mcmcplot`. The beauty of it is that once it takes the posterior draws, it doesn’t send the output to the R plot window as usual, but instead it compiles the plots in html format, opens the default browser straight away, and let you visualise all the graphs in an indexed webpage into a browsing window. Alternatively, it’s also possible to save the diagnostics’ plots into a folder, with the `dir` option. It generates trace, autocorrelation, and density plots (not the Gelman plot unfortunately). Another feature I really appreciated of `mcmcplot` is the possibility of randomly drawing subsets of parameters not to explore, as in my case, literally thousands graphs. Simple and effective.
Here is a screenshot with the output and some code.