Skip to contents

brms's plot() of a fit: for each selected parameter a histogram and a trace of its draws, nvariables parameters to a page, drawn with bayesplot::mcmc_combo(). The arguments are brms's, in brms's order and with brms's defaults. Without pars or variable the parameters are the model's outer parameters (no group-level coefficients), as brms leaves out its r_ draws.

Usage

# S3 method for class 'frmtmb_draws'
plot(
  x,
  pars = NA,
  combo = c("hist", "trace"),
  nvariables = 5,
  N = NULL,
  variable = NULL,
  regex = FALSE,
  fixed = FALSE,
  bins = 30,
  theme = NULL,
  plot = TRUE,
  ask = TRUE,
  newpage = TRUE,
  ...
)

Arguments

x

A frmtmb_draws from frm_sample().

pars, variable, regex, fixed

Which parameters, by brms's rule: variable is exact names unless regex = TRUE; pars is a regular expression unless fixed = TRUE, and wins when both are given.

combo

The two bayesplot panel types, as in brms.

nvariables

Parameters per page.

N

brms's deprecated alias of nvariables, with brms's warning.

bins

Histogram bins.

theme

A ggplot2 theme for the panels.

plot

If FALSE, return the pages without drawing them.

ask

Whether to ask before each page after the first.

newpage

Whether the first page starts a new page.

...

Passed to bayesplot::mcmc_combo().

Value

The pages, a list of bayesplot grids, invisibly.

Examples

# \donttest{
if (requireNamespace("tmbstan", quietly = TRUE) &&
    requireNamespace("rstan", quietly = TRUE) &&
    requireNamespace("bayesplot", quietly = TRUE) &&
    !frmtmb.sample:::tmbstan_build_broken()) {
  set.seed(1)
  dd <- data.frame(x = rnorm(40))
  dd$y <- rnorm(40, 1 + 0.5 * dd$x, 1)
  ds <- frm_sample(bf(y ~ x), family = gaussian(), data = dd,
                   chains = 1, iter = 400, refresh = 0)
  plot(ds, variable = "^b_", regex = TRUE, ask = FALSE)
}
#> frm_sample(): default priors (brms 2.23 defaults; prior = "flat" puts brms's (flat) in every slot)
#>   Intercept          student_t(3, 1.1, 2.5)
#>   sigma              student_t(3, 0, 2.5)  [natural scale]
#>   b                  (flat), as brms leaves slopes
#> Warning: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
#> Running the chains for more iterations may help. See
#> https://mc-stan.org/misc/warnings.html#bulk-ess

# }