Skip to contents

Plot pairwise parameter posteriors and optionally the MLE points and confidence ellipses. This function is modified from the base pairs code to work specifically with fits from the 'SparseNUTS' package using either the NUTS or RWM MCMC algorithms. If an invertible Hessian was found (in fit$mle) then estimated covariances are available to compare and added automatically (red ellipses). Likewise, a "monitor" object from rstan::monitor is attached as fit$monitor and provides effective sample sizes (ESS) and Rhat values. The ESS are used to potentially order the parameters via argument order, but also printed on the diagonal.

Usage

pairs_rtmb(
  fit,
  pars = NULL,
  order = c("orig", "slow", "fast", "mismatch", "divergent"),
  diag = c("trace", "acf", "hist"),
  inc_warmup = FALSE,
  add_mle = TRUE,
  add_monitor = TRUE,
  unbounded = FALSE
)

Arguments

fit

A list as returned by sample_nuts.

pars

A character vector of parameters or integers representing which parameters to subset. Useful if the model has a larger number of parameters and you just want to show a few key ones.

order

The order to consider the parameters. Options are 'orig' (default) to use the order declared in the model, or 'slow' and 'fast' which are based on the effective sample sizes ordered by slowest or fastest mixing respectively. Finally 'mismatch' is for parameters with large discrepancies between the MLE and posterior marginal variances, defined as the absolute relative difference of the MLE from the posterior i.e., abs((mle-post)/post). See example for usage.

diag

What type of plot to include on the diagonal, options are 'acf' which plots the autocorrelation function acf, 'hist' shows marginal posterior histograms, and 'trace' the trace plot.

inc_warmup

Whether to include the warmup samples or not (default).

add_mle

Boolean whether to add 95% confidence ellipses.

add_monitor

Boolean whether to print effective sample size (ESS).

unbounded

Whether to use the bounded or unbounded version of the parameters.

Value

a ggplot.