denoverplot {mcmcplots} | R Documentation |
Overlaying Densities for Parameters from two MCMC Simulations.
Description
Determines which parameters are in common from two different MCMC simulations and plots overlaying density estimates of the parameters in common.
Usage
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 |
mcmc2 |
object that can be coerced to an |
parms |
character vector specifying which subsets of parameters to plot. If |
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 |
ci |
if non |
auto.layout |
logical specifying whether the |
legend |
if |
mar |
argument passed to |
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 |
greek |
if |
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 |
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
Examples
## 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)