README.md

MCMCwrap

Organize MCMC output (coda/r2jags mcmc.list objects) for analysis and plotting

Description

Description: The 'coda' package (maintainer: Martyn Plummer plummerm@iarc.fr is commonly used to carry out Markov Chain Monte Carlo simulations, especially for the analysis of Bayesian hierarchical models in JAGS (Just Another Gibbs Sampler - also maintained by Plummer). Package 'coda' has a ton of built-in functions for viewing and assessing MCMC outputs, but the actual values it draws from posterior distributions tend to end up buried inside complex package-specific objects. MCMCwrap provides wrapper functions for extracting MCMC posterior draws and modes from mcmc.list objects, generated by coda and organizing them into arrays for easy plotting and external diagnostics.

Contents

  1. MCMCout for extracting posterior draws, means, and modes from mcmc.list objects.
  2. MCMCout_mix for the same, but from mixing models
  3. Installation
  4. Contact the author

1. MCMCout

Get posterior draws, means, and modes output by MCMC simulations.

MCMC_out(x, ...)

Example Usage

mod1 <- jags.model(model_script, data = list(<data>), 
    inits = function()list(<inits>), n.chains = 3, n.adapt = 2000)
update(mod1, n.iter=5e3)
mod1_out <- coda.samples(mod1, c(<variables out>, n.iter=1e5, thin=100))
MCMCout(mod1_out)

1. MCMCout_mix

Get posterior draws, means, and modes output by mixing models.

MCMCout_mix(x, p, nsrc, ...)

Example Usage

mod1 <- jags.model(model_script, data = list(<data>), 
    inits = function()list(<inits>), n.chains = 3, n.adapt = 2000)
update(mod1, n.iter=5e3)
mod1_out <- coda.samples(mod1, c(<variables out>, n.iter=1e5, thin=100))
MCMCout_mix(model_output, 'prey_proportion', 3)

6. Installation

# devtools lets you install packages from GitHub:
install.packages('devtools')
library(devtools)

# then it's this simple:
install_github('vlahm/MCMCwrap')
library(MCMCwrap)

7. Contact the author

Mike Vlah: + vlahm13@gmail[dot]com + linkedin.com/in/michaelvlah



vlahm/MCMCwrap documentation built on May 3, 2019, 6:16 p.m.