View source: R/viz_prof.plot.R
prof.plot | R Documentation |
This function plots histograms/densities ("profiles") of posterior samples for particular parameters from an evorates_fit
object or param_block
array.
prof.plot(
x,
smooth = FALSE,
p = 0.05,
lower.quant = NULL,
upper.quant = NULL,
lower.cut = NULL,
upper.cut = NULL,
add.lines = NULL,
quant.lines = TRUE,
add = FALSE,
make.legend = TRUE,
include.chain.legend = TRUE,
...,
param.args = c("col", "border", "lines.col", "alpha", "border.alpha", "lines.alpha"),
chain.args = c("angle", "density"),
inpar.args = c("lines.lty", "lines.lwd")
)
x |
The parameters to be plotted. Typically, this is a |
smooth |
|
p |
A numeric vector controlling the widths of the shaded portions of profiles for each parameter. Specifically, the shaded
region is the |
lower.quant , upper.quant |
Numeric vectors specifying the boundaries of the shaded portions of profiles for each
parameter based on posterior quantiles. Set to |
lower.cut , upper.cut |
Numeric vectors specifying the boundaries of the shaded portions of profiles for each
parameter (on the x-axis scale, rather than quantile-based). Notably, these can be used plot credible intervals based on the
highest posterior density regions, rather than quantiles as is done by default (see examples below). Set to |
add.lines |
A numeric vector specifying where to plot lines over profiles. This is not yet "vectorized", and will plot the same lines
for all profiles (though I hope to change this in the future)! Can be specified via posterior quantiles if |
quant.lines |
|
add |
|
make.legend |
|
include.chain.legend |
|
... |
Other arguments, such as graphical parameters or arguments to pass to
|
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:
trace.plot()
#get whale/dolphin evorates fit
data("cet_fit")
#plot some parameters
prof.plot(cet_fit %chains% c("R_0", "R_mu"), alpha = 0.5)
#the above is equivalent to:
prof.plot(c("R_0", "R_mu"), alpha = 0.5, fit = cet_fit)
#could also something like this:
par <- get.bg.rate(fit = cet_fit,
node.groups = setNames(list('Mesoplodon','Orcinus',c('Pseudorca','Feresa')),
c('Mesoplodon','Orca','Globicephalinae')),
)
prof.plot(par, alpha = 0.5)
#or even:
prof.plot(list(par, "R_0"), alpha = 0.5, fit = cet_fit)
#some ways the plot style might be tweaked:
prof.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),
breaks = 100,
col = c('blue','red','green','black'), alpha = 0.1, border.alpha = 0.25,
add.lines = c(0.25, NA, 0.75), lines.lwd = c(2, 3, 2), lines.lty = c(3, 2, 3),
bty='n', legend.bty = 'n', legend.inset = c(0.1, 0), lwd = 2)
#may want to "smooth out" profiles!
prof.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),
smooth = TRUE, bw = 0.1,
col = c('blue','red','green','black'), alpha = 0.1, border.alpha = 0.25,
add.lines = c(0.25, NA, 0.75), lines.lwd = c(2, 3, 2), lines.lty = c(3, 2, 3),
bty='n', legend.bty = 'n', legend.inset = c(0.1, 0), lwd = 2)
#try some narrower credible intervals?
prof.plot(list(par, "R_0"), fit = cet_fit, p = 0.5,
overwrite.param.names = expression("ln"~sigma["Meso"]^2,
"ln"~sigma["Orca"]^2,
"ln"~sigma["Glob"]^2,
"ln"~sigma["Root"]^2),
smooth = TRUE, bw = 0.1,
col = c('blue','red','green','black'), alpha = 0.1, border.alpha = 0.25,
add.lines = c(0.25, NA, 0.75), lines.lwd = c(2, 3, 2), lines.lty = c(3, 2, 3),
bty='n', legend.bty = 'n', legend.inset = c(0.1, 0), lwd = 2)
#or intervals based on highest posterior density regions
#(have to combine chains since different cuts for the same parameters aren't yet allowed)
#(requires HDInterval package)
fit <- combine.chains(cet_fit)
combined.par <- get.bg.rate(fit = fit,
node.groups = setNames(list('Mesoplodon','Orcinus',c('Pseudorca','Feresa')),
c('Mesoplodon','Orca','Globicephalinae')),
)
tmp <- par.c(combined.par, "R_0", fit = fit)
tmp <- apply(tmp, 2, HDInterval::hdi)
prof.plot(list(combined.par, "R_0"), fit = fit, lower.cut = tmp[1,], upper.cut = tmp[2,],
overwrite.param.names = expression("ln"~sigma["Meso"]^2,
"ln"~sigma["Orca"]^2,
"ln"~sigma["Glob"]^2,
"ln"~sigma["Root"]^2),
smooth = TRUE, bw = 0.1,
col = c('blue','red','green','black'), alpha = 0.1, border.alpha = 0.25,
add.lines = c(0.25, NA, 0.75), lines.lwd = c(2, 3, 2), lines.lty = c(3, 2, 3),
bty='n', legend.bty = 'n', legend.inset = c(0.1, 0), lwd = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.