stan_caterpillar: Create caterpillar plots from rstan's stanfit objects

View source: R/stan_caterpillar.R

stan_caterpillarR Documentation

Create caterpillar plots from rstan's stanfit objects

Description

Create caterpillar plots from rstan's stanfit objects

Usage

stan_caterpillar(
  obj,
  pars,
  pars_labels = NULL,
  hpd = TRUE,
  order_medians = TRUE,
  horizontal = TRUE,
  alpha_bounds = 0.3
)

Arguments

obj

a stanfit object

pars

scalar or vector regular expressions for parameter labels that you would like to plot as declared in model_code from the stan call.

pars_labels

vector of parameter labels for the output plot. Important: they must be in the same order as in the stanfit object when as.data.frame(obj) is called.

hpd

logical. If TRUE then the 90% and 95% highest probability density intervals (HDI) are found. If FALSE then the corresponding central intervals are found.

order_medians

logical. Whether or not to order the points by their medians.

horizontal

logical. Whether or not you would like the lines to be horizontal

alpha_bounds

numeric. Alpha transparency value for the uncertainty bounds.

Details

Points plot the simulations' medians, thin lines represent the 95 HPD/central intervals, and thick lines represent the 90 intervals.

See Also

rstan, stan, ggmcmc

Examples

## Not run: 
# Create Stan model
library(rstan)
scode <- "
   parameters {
       real y[2];
   }
   model {
       y[1] ~ normal(0, 1);
       y[2] ~ double_exponential(0, 2);
   }
"

# Run
fit <- stan(model_code = scode, iter = 10000, verbose = FALSE)

# Plot y[1] and y[2] parameters
stan_caterpillar(fit, pars = 'y\\[.*\\]')

## End(Not run)


christophergandrud/StanCat documentation built on Jan. 6, 2023, 10:49 p.m.