Allows quick visualization of posterior density and trace plots, both separated by chain, for the desired nodes of interest. Includes the ability to plot in the RStudio graphics device, an external device, or a PDF file. Further, with the auto settings, the dimensions of the plotting device scales to the job needed.
diag_plots( post, params, ext_device = FALSE, show_diags = "if_poor_Rhat", layout = "auto", dims = "auto", keep_percent = 1, save = FALSE, file = NULL, auto_escape = TRUE )
post | A |
---|---|
params | A vector of regular expressions specifying the nodes to match for plotting.
Accepts multi-element vectors to match more than one node at a time.
See |
ext_device | Display plots in an external device rather than the active device?
|
show_diags | Control when to display numerical diagnostic summaries on plots. Must be one of
|
layout | Control how parameter diagnostics are organized into |
dims | Control the dimensions of the graphics device using |
keep_percent | Proportion (between 0 and 1) of samples to keep for trace plotting.
Passed to |
save | Save the diagnostic plots in a PDF file? If so,
specify |
file | File name of a PDF file to save the plots to.
Must include the |
auto_escape | Automatically escape |
A multi-panel figure showing the posterior density and trace plots for requested nodes. The device in which it is placed depends on the argument values.
If saving as a pdf, these files can get very large with many samples and render slowly.
The keep_percent
argument is intended to help with this by thinning the chains at quasi-evenly spaced intervals.
if (interactive()) { #load example mcmc.list data(cjs) # use current device diag_plots(cjs, "B0") # use a new device diag_plots(cjs, "B0", ext_device = TRUE) # always show diagnostic summaries diag_plots(cjs, "B0", show_diags = "always") # use a different layout (leaving it as "auto" is usually best) diag_plots(cjs, c("sig", "b"), layout = "5x3") # save diagnostics for all nodes to a pdf file diag_plots(cjs, "", save = TRUE, file = "diags.pdf") }