ggChains {CNPBayes}R Documentation

Trace plots of MCMC chains and mixture model densities

Description

The ggChains method provides a convenient wrapper for plotting the chains of all parameters in the various mixture model implementations. In addition to the estimated number of independent MCMC draws (effective sample size) and Gelman-Rubin convergence diagnostics implemented in gibbs, visualization of the chains is helpful for assessing convergence.

ggplot-style functions for diagnosing convergence

Usage

ggChains(model)

ggMixture(model, bins)

ggSingleBatch(model, bins)

ggMultiBatch(model, bins)

ggSingleBatchChains(model)

## S4 method for signature 'MultiBatchCopyNumber'
ggMixture(model, bins)

## S4 method for signature 'MultiBatchCopyNumberPooled'
ggMixture(model, bins)

## S4 method for signature 'SingleBatchModel'
ggMixture(model, bins)

## S4 method for signature 'MultiBatchModel'
ggMixture(model, bins)

## S4 method for signature 'MultiBatchPooled'
ggMixture(model, bins)

## S4 method for signature 'SingleBatchCopyNumber'
ggMixture(model, bins)

## S4 method for signature 'MultiBatchModel'
ggChains(model)

## S4 method for signature 'MultiBatchPooled'
ggChains(model)

## S4 method for signature 'SingleBatchPooled'
ggChains(model)

## S4 method for signature 'SingleBatchModel'
ggChains(model)

Arguments

model

A SB, MB, SBP, or MBP model

bins

a length-one numeric vector indicating the number of bins – passed to geom_hist

Details

The ggMixture method overlays the posterior approximation of the Gaussian mixture on the empirical data.

Value

A gg object

a ggplot object

a list of ggplot objects. Chains are grouped by the length of the parameter vector. For example, in the single-batch model, the means (theta) and variances (sigma2) are component-specific (length k, where k is number of components) and are plotted together in a single ggplot object.

See Also

gibbs

Examples

  sb <- SingleBatchModelExample
  iter(sb, force=TRUE) <- 1000
  burnin(sb) <- 100
  sb <- posteriorSimulation(sb)
  fig.chains <- ggChains(sb)
  ## component-specific chains
  fig.chains[["comp"]]
  ## single-parameter chains and log-likelihood
  fig.chains[["single"]]

  ## plot the mixture
  fig.mix <- ggMixture(sb)
sb <- SingleBatchModelExample
plist.sb <- ggChains(sb)
## Not run: 
## chains for parameter vectors of length k
plist.sb[["comp"]]
## chains for parameters vectors of length 1
plist.sb[["single"]]

## End(Not run)

mb <- MultiBatchModelExample
plist.mb <- ggChains(mb)
## Not run: 
## chains for parameters that are batch- and component-specific
plist.mb[["batch"]]
## chains for parameters vectors of length k
plist.mb[["comp"]]
## chains for parameter vectors of length 1
plist.mb[["single"]]

## End(Not run)

[Package CNPBayes version 1.10.0 Index]