mcmc_plot.brmsfit: MCMC Plots Implemented in 'bayesplot'

View source: R/plot.R

mcmc_plot.brmsfitR Documentation

MCMC Plots Implemented in bayesplot

Description

Convenient way to call MCMC plotting functions implemented in the bayesplot package.

Usage

## S3 method for class 'brmsfit'
mcmc_plot(
  object,
  pars = NA,
  type = "intervals",
  variable = NULL,
  regex = FALSE,
  fixed = FALSE,
  ...
)

mcmc_plot(object, ...)

Arguments

object

An R object typically of class brmsfit

pars

Deprecated alias of variable. Names of the parameters to plot, as given by a character vector or a regular expression.

type

The type of the plot. Supported types are (as names) hist, dens, hist_by_chain, dens_overlay, violin, intervals, areas, acf, acf_bar,trace, trace_highlight, scatter, rhat, rhat_hist, neff, neff_hist nuts_acceptance, nuts_divergence, nuts_stepsize, nuts_treedepth, and nuts_energy. For an overview on the various plot types see MCMC-overview.

variable

Names of the variables (parameters) to plot, as given by a character vector or a regular expression (if regex = TRUE). By default, a hopefully not too large selection of variables is plotted.

regex

Logical; Indicates whether variable should be treated as regular expressions. Defaults to FALSE.

fixed

(Deprecated) Indicates whether parameter names should be matched exactly (TRUE) or treated as regular expressions (FALSE). Default is FALSE and only works with argument pars.

...

Additional arguments passed to the plotting functions. See MCMC-overview for more details.

Details

Also consider using the shinystan package available via method launch_shinystan in brms for flexible and interactive visual analysis.

Value

A ggplot object that can be further customized using the ggplot2 package.

Examples

## Not run: 
model <- brm(count ~ zAge + zBase * Trt + (1|patient),
             data = epilepsy, family = "poisson")

# plot posterior intervals
mcmc_plot(model)

# only show population-level effects in the plots
mcmc_plot(model, variable = "^b_", regex = TRUE)

# show histograms of the posterior distributions
mcmc_plot(model, type = "hist")

# plot some diagnostics of the sampler
mcmc_plot(model, type = "neff")
mcmc_plot(model, type = "rhat")

# plot some diagnostics specific to the NUTS sampler
mcmc_plot(model, type = "nuts_acceptance")
mcmc_plot(model, type = "nuts_divergence")

## End(Not run)


brms documentation built on Sept. 23, 2024, 5:08 p.m.