caterpillar: Caterpillar plot

View source: R/caterpillar.R

caterpillarR Documentation

Caterpillar plot

Description

Caterpillar plot of the posterior densities of a vector of parameter nodes, in which the sequential order of nodes might not be important, such as vector of random effects.

This produces a set of overlayed interval bars (default values are 50 percent and 95 percent), with overlayed median markings, for each of a vector of parameter nodes.

Usage

caterpillar(
  df,
  p = NULL,
  x = NA,
  row = NULL,
  column = NULL,
  median = TRUE,
  mean = FALSE,
  ci = c(0.5, 0.95),
  lwd = 1,
  col = 4,
  add = FALSE,
  xlab = "",
  ylab = "",
  main = NULL,
  ylim = NULL,
  xax = NA,
  transform = c("none", "exp", "expit"),
  medlwd = lwd,
  medwd = 1,
  ...
)

Arguments

df

Output object returned from jagsUI::jags(); or alternately, two-dimensional data.frame or matrix in which parameter node element is given by column and MCMC iteration is given by row. A vector may also be used, that expresses MCMC iterations of a single parameter node.

p

Parameter name, if input to df is a jagsUI output object.

x

Vector of X-coordinates for plotting.

row

Row to subset, in the case of a 2-d matrix of parameter nodes in-model.

column

Column to subset, in the case of a 2-d matrix of parameter nodes in-model.

median

Whether to include medians

mean

Whether to include means

ci

Vector of intervals to overlay. Defaults to 50 percent and 95 percent.

lwd

Base line width for plotting. Defaults to 1.

col

Color for plotting

add

Whether to add to existing plot

xlab

X-axis label

ylab

Y-axis label

main

Plot title. If the default (NULL) is accepted and argument p is used, p will be used for the title.

ylim

Y-axis limits. If the default (NULL) is accepted, the limits will be determined automatically.

xax

Vector of possible x-axis tick labels. Defaults to the data.frame column names.

transform

Should the y-axis be (back)transformed? Options are "exp", indicating exponential, or "expit", indicating inverse-logit. Defaults to "none", indicating no transformation. Note: if transform="exp"is used, consider adding additional plotting argument log="y".

medlwd

Line width of median line

medwd

Relative width of median line. Defaults to 1, perhaps smaller numbers will look better?

...

additional plotting arguments

Value

NULL

Author(s)

Matt Tyers

See Also

envelope, crossplot

Examples

## usage with input data.frame
a <- jags_df(asdf_jags_out, p="a")

caterpillar(a)
caterpillar(a, ci=seq(.1,.9,by=.1))
caterpillar(a, lwd=2)
caterpillar(a, xax=c("effect 1", "effect 2", "effect 3"))


## usage with input as jagsUI object
caterpillar(asdf_jags_out, p="a")
caterpillar(SS_out, p="rate")

## usage with a 2-d parameter matrix
caterpillar(SS_out, p="cycle_s", column=1)
caterpillar(SS_out, p="cycle_s", column=2)

## usage with an exponential transformation
caterpillar(SS_out, p="trend", transform="exp", ylab="exp transform")
caterpillar(SS_out, p="trend", transform="exp", ylab="exp transform", log="y")
caterpillar(SS_out, p="trend", transform="expit", ylab="expit (inv logit) transform")

jagshelper documentation built on Oct. 22, 2024, 1:06 a.m.