Tidying up MCMC output can be a real pain. There are plenty of packages that help with summarising MCMC and providing their own summaries, but sometimes you just want a tidy datastructure so you can do your own thing. And quickly.

mmcc provides tidying functions that return tidy data structure from mcmc.list objects. It uses data.table as the backend for speediness, it also provides broom tidiers to assist in some quick summaries.


Install from github using:

Usingage mmcc

mcmc_to_dt takes an mcmc.list object and turns it into a data.table of the format:

tidy.mcmc.list takes an mcmc.list, turns it into a data.table and summarises it in terms of each parameter’s mean, median, standard deviation and credible interval with level given by conf.level:

We can also optionally ask for a subset of the parameters with a vector of colnames and summarise for each chain:

This may be useful if we want to make a plot that shows how a given parameter varies from chain to chain.


line_tidy <- tidy(line, chain = TRUE)

ggplot(data = line_tidy, 
       aes(x = factor(chain), 
           y = mean)) +
    geom_pointrange(aes(ymin = `2.5%`,
                        ymax = `97.5%`)) +
               nrow = 1, 
               scales = "free_y") +
    theme_bw() +
    xlab("Chain") +

Why mmcc?

Full credit does to Sam Clifford for the name.

To quote Sam:

…it’s all about reshaping and manipulating mcmc chains…

…therefore, mmcc

Future work

  • Create summaries for each parameter
  • Perform diagnostic summaries for convergence
  • provide a suite of plotting in plotly, for speed, and interactivity.

Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.