denoverplot: Overlaying Densities for Parameters from two MCMC...

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Determines which parameters are in common from two different MCMC simulations and plots overlaying density estimates of the parameters in common.

Usage

1
2
3
4
5
denoverplot(mcmc1, mcmc2, parms = NULL, regex = NULL, random = NULL,
ci = NULL, auto.layout = TRUE, legend = TRUE,
mar = c(2.0, 2.0, 1.5, 0.25) + 0.1, col = mcmcplotsPalette(2),
lty = 1, plot.title = NULL, main = NULL, greek =FALSE,
style = c("gray", "plain"), ...)

Arguments

mcmc1

object that can be coerced to an mcmc object.

mcmc2

object that can be coerced to an mcmc object.

parms

character vector specifying which subsets of parameters to plot. If NULL and regex=NULL, denoverplot will plot all common parameters mcmc1 and mcmc2. See documentation for parms2plot for more information.

regex

character vector of regular expressions denoting groups of parameters to plot.

random

integer specifying how many parameters from each group will be randomly selected for plotting. This argument is useful when mcmcout has a large number of parameters (e.g., from a hierarchical model). If NULL, mcmcplot will plot all parameters.

ci

if non NULL, plots (100*ci)% credible interval limits on the density plots. The default (ci=NULL) is not to plot the intervals.

auto.layout

logical specifying whether the mult.fig function from the sfsmisc package should be used to construct the plotting region.

legend

if TRUE an extra plot in the plotting region is used as a legend.

mar

argument passed to multi.fig if auto.layout=TRUE

col

colors for plotting the densites.

lty

line types for plotting densities. Argument is recylced to be of length 2.

plot.title

title to put in the outer margin. Default is no title.

main

character vector of titles to put over each individual plot. If NULL, then the names of the parameters are used.

greek

if TRUE, the names of greek letters in the labels will be displayed as greek characters on the plot.

style

if "gray", then the plotting region is printed with a gray background, otherwise the default plotting region is used.

...

additional arguments passed to the denoverplot function.

Details

This function can be used in debugging MCMC code by comparing distributions of parameters from the development MCMC code and a reference MCMC simulation.

Value

Creates a plot.

Author(s)

S. McKay Curtis

See Also

denplot, parms2plot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Create fake MCMC output
nc <- 10; nr <- 1000
pnames <- c(paste("alpha[", 1:5, "]", sep=""), paste("gamma[", 1:5, "]", sep=""))
means <- rpois(10, 20)
fakemcmc <- coda::as.mcmc.list(
    lapply(1:3,
           function(i) coda::mcmc(matrix(rnorm(nc*nr, rep(means, each=nr)),
                                         nrow=nr, dimnames=list(NULL,pnames)))))
fakemcmc2 <- coda::as.mcmc.list(
    lapply(1:3,
           function(i) coda::mcmc(matrix(rnorm(nc*nr, rep(means, each=nr)),
                                         nrow=nr, dimnames=list(NULL,pnames)))))

## Plot the fake MCMC output
denoverplot(fakemcmc, fakemcmc2)
denoverplot(fakemcmc, fakemcmc2, style="plain",
            col=mcmcplotsPalette(3, type="grayscale"),
            ci=0.95, greek=TRUE)
denoverplot(fakemcmc, fakemcmc2,
            plot.title="Comparison of densities of fake data")
denoverplot(fakemcmc, fakemcmc2,
            plot.title="Comparison of densities of fake data", greek=TRUE)

mcmcplots documentation built on May 2, 2019, 1:29 p.m.