View source: R/VIZ_trace.plot.R
trace.plot | R Documentation |
This function plots posterior samples as a function of iterations ("traces") for particular parameters from an evorates_fit
object or param_block
array.
trace.plot(
x,
ribbon = TRUE,
ribbon.first = FALSE,
n.windows = 50,
window.size = NULL,
p = 0.05,
lower.quant = NULL,
upper.quant = NULL,
add.lines = NULL,
add = FALSE,
make.legend = TRUE,
include.chain.legend = TRUE,
...,
param.args = c("col", "lines.col", "alpha", "lines.alpha", "ribbon.col",
"ribbon.border", "ribbon.alpha", "ribbon.border.alpha"),
chain.args = c("ribbon.angle", "ribbon.density"),
inpar.args = c("lines.lty", "lines.lwd")
)
x |
The parameters to be plotted. Typically, this is a |
ribbon |
|
ribbon.first |
|
n.windows |
The number of windows used to calculate "rolling" quantiles for ribbons. Windows are centered such that chains
are broken into approximately equal intervals (i.e., specfying 10 windows for 1000 iterations will result in windows centered at
iterations 1, 112, 223, 334, ..., 1000). Also specifies number of windows used for lines defined by |
window.size |
The size of windows used to calculate "rolling" quantiles for ribbons. If |
p |
A numeric vector controlling the width of ribbons for each parameter. Specifically, the shaded
region is the "rolling" |
lower.quant , upper.quant |
Numeric vectors specifying the boundaries of ribbons for each
parameter based on posterior quantiles. Set to |
add.lines |
A numeric vector specifying additional "rolling" quantiles to plot over traces. This is not yet "vectorized",
and will plot the same lines for all traces (though I hope to change this in the future)! |
add |
|
make.legend |
|
include.chain.legend |
|
... |
Other arguments, such as graphical parameters. Here are the some commonly-used ones:
|
param.args , chain.args , inpar.args |
Generally, these should not be altered, but are exposed here for the curious to play around
with. These are vectors of argument names for graphical parameters that control whether the graphical parameters vary by the
parameter the profile corresponds to ( |
Nothing as of now–this function just makes a plot!
Other evorates plotting functions:
prof.plot()
#get whale/dolphin evorates fit
data("cet_fit")
#plot some parameters
trace.plot(cet_fit %chains% c("R_sig2", "R_mu"))
#the above is equivalent to:
trace.plot(c("R_sig2", "R_mu"), fit = cet_fit)
#could also do something like this:
par <- get.bg.rate(fit = cet_fit,
node.groups = setNames(list('Mesoplodon','Orcinus',c('Pseudorca','Feresa')),
c('Mesoplodon','Orca','Globicephalinae')),
)
trace.plot(par)
#or even:
trace.plot(list(par, "R_0"), fit = cet_fit)
#some ways the plot style might be tweaked:
trace.plot(list(par, "R_0"), fit = cet_fit,
overwrite.param.names = expression("ln"~sigma["Meso"]^2,
"ln"~sigma["Orca"]^2,
"ln"~sigma["Glob"]^2,
"ln"~sigma["Root"]^2),
col = c('blue','red','green','black'), alpha = 0.2, lty=1,
ribbon = FALSE,
add.lines = c(0.025, 0.25, NA, 0.75, 0.975),
lines.alpha = 0.3, lines.lwd = c(1, 2, 3, 2, 1), lines.lty = c(3, 2, 1, 2, 3),
bty='n', legend.bty = 'n', legend.x = "topleft", legend.horiz = TRUE, include.chain.legend = FALSE)
#may want rougher, more finely-grained rolling quantiles?
trace.plot(list(par, "R_0"), fit = cet_fit,
overwrite.param.names = expression("ln"~sigma["Meso"]^2,
"ln"~sigma["Orca"]^2,
"ln"~sigma["Glob"]^2,
"ln"~sigma["Root"]^2),
col = c('blue','red','green','black'), alpha = 0.2, lty=1,
ribbon = FALSE, n.windows = 100, window.size = 50,
add.lines = c(0.025, 0.25, NA, 0.75, 0.975),
lines.alpha = 0.3, lines.lwd = c(1, 2, 3, 2, 1), lines.lty = c(3, 2, 1, 2, 3),
bty='n', legend.bty = 'n', legend.x = "topleft", legend.horiz = TRUE, include.chain.legend = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.