Learn R Programming

ggmcmc (version 0.3)

ggs: Import MCMC samples into a ggs object than can be used by all ggs_* graphical functions.

Description

This function manages MCMC samples from different sources (JAGS, MCMCpack, STAN -both via rstan and via csv files-) and converts them into a data frame. The resulting data frame has four columns (Iteration, Parameter, value, Chain) and seven attributes (nChains, nParameters, nIterations, nBurnin, nThin, description and parallel). The ggs object returned is then used as the input of the ggs_* functions to actually plot the different convergence diagnostics.

Usage

ggs(S, description = NA, burnin = FALSE,
    inc_warmup = FALSE, stan_include_auxiliar = FALSE,
    parallel = TRUE)

Arguments

S
Either a mcmc.list object with samples from JAGS, a mcmc object with samples from MCMCpack, a stanfit object with samples from rstan, or a list with the filenames of csv files generated by stan o
description
Character vector giving a short descriptive text that identifies the model.
burnin
Logical or numerical value. When logical and TRUE, the number of samples in the burnin period will be taken into account, if it can be guessed by the extracting process. Otherwise, iterations will start counting from 1. Defaults to FALSE. If a num
inc_warmup
Logical. When dealing with stanfit objects from rstan, logical value whether the warmup samples are included. Defaults to FALSE.
stan_include_auxiliar
Logical value to include "lp__" parameter in rstan, and "lp__", "treedepth__" and "stepsize__" in stan running without rstan. Defaults to FALSE.
parallel
Logical value for using parallel computing when managing the data frame in other functions. Defaults to TRUE, although it has not been fully tested yet.

Value

  • D A data frame with the data arranged and ready to be used by the rest of the ggmcmc functions. The data frame has four columns, namely: Iteration, Parameter, value and Chain, and seven attributes: nChains, nParameters, nIterations, nBurnin, nThin, description and parallel.

Examples

Run this code
# Assign 'D' to be a data frame suitable for \\code{ggmcmc} functions from
# a coda object called S
data(samples)
D <- ggs(S)        # S is a coda object

Run the code above in your browser using DataLab