Description Usage Arguments Value Author(s) See Also Examples
This function produces trace plots from an MCMC simulation on a single plot for all parameters (by default) or those parameters indicated by the parms
argument.
1 2 3 4 5 |
mcmcout |
an 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 |
an integer indicating the maximum number of parameters to randomly select for plotting from each group of parameters as specified by the |
leaf.marker |
a regular expression with a character class that marks the beginning of the “leaf” portion of a parameter name. The default character class includes |
ylim |
limits for the y-axis. |
auto.layout |
automatically creates a plot layout using |
mar |
argument passed to |
col |
colors to be used in plotting the densities. Default is |
lty |
line types to be used in plotting. |
plot.title |
title to put in the outer margin. Default is no title. |
main |
main title for the plots. Default is to use parameter names. |
greek |
if |
style |
if "gray", then the plotting region is printed with a gray background, otherwise the default plotting region is used. |
... |
further arguments passed to the plotting function. |
Creates a plot.
S. McKay Curtis
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | ## 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)))))
## Plot traces of the fake MCMC output
traplot(fakemcmc)
traplot(fakemcmc, style="plain")
traplot(fakemcmc, "gamma", greek=TRUE)
## What happens with NULL varnames?
coda::varnames(fakemcmc) <- NULL
traplot(fakemcmc)
## Not run:
## traplot works on bugs objects too
library(R2WinBUGS)
example("openbugs", "R2WinBUGS")
## from the help file for openbugs:
schools.sim <- bugs(data, inits, parameters, model.file,
n.chains = 3, n.iter = 5000,
program = "openbugs", working.directory = NULL)
traplot(schools.sim, "theta")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.