overlayenvelope {jagshelper}R Documentation

Overlay envelope plots

Description

Overlays multiple envelope plots of posterior data.frames, or outputs returned from jagsUI. This would be best suited to a set of posterior data.frames or 2-d matrices representing sequential vectors of parameter nodes.

Here a single envelope plot is defined as a set of overlayed shaded strips, each corresponding to a given interval width (defaults to 50 percent and 95 percent), with an overlayed median line.

Usage

overlayenvelope(
  df,
  p = NULL,
  x = NA,
  row = NULL,
  column = NULL,
  median = TRUE,
  ci = c(0.5, 0.95),
  col = NULL,
  add = FALSE,
  dark = 0.3,
  outline = FALSE,
  xlab = "",
  ylab = "",
  main = NULL,
  ylim = NULL,
  legend = TRUE,
  legendnames = NULL,
  legendpos = "topleft",
  transform = c("none", "exp", "expit"),
  ...
)

Arguments

df

Primary input can be specified in a number of ways: either a list() of posterior data.frames or matrices, a list of output objects returned from jagsUI::jags(), a 3-dimensional array in which the input matrices to plot are separated according to the 3rd array dimension, or a single output object returned from jagsUI::jags() with multiple arguments passed to p, following.

p

Parameter name, if input to df is a list of jagsUI output objects; or a vector of parameter names, if input to df is a single jagsUI output object.

x

Optional 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 median line

ci

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

col

Vector of colors for plotting

add

Whether to add to existing plot

dark

Opacity (0-1) for envelopes. Note that multiple overlapping intervals will darken the envelope. Defaults to 0.3.

outline

Whether to just envelope outlines

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 for plotting. If the default (NULL) is accepted, these will be determined automatically.

legend

Whether to automatically try to add a legend. Defaults to TRUE.

legendnames

Optional vector of names for a legend.

legendpos

Position for optional legend. Defaults to "topleft".

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".

...

additional plotting arguments or arguments to lines()

Value

NULL

Author(s)

Matt Tyers

See Also

envelope

Examples

## usage with list of input data.frames
overlayenvelope(df=list(SS_out$sims.list$cycle_s[,,1],
                            SS_out$sims.list$cycle_s[,,2]))

## usage with a 3-d input array
overlayenvelope(df=SS_out$sims.list$cycle_s)

## usage with a jagsUI output object and parameter name (2-d parameter)
overlayenvelope(df=SS_out, p="cycle_s")

## usage with a single jagsUI output object and multiple parameters
overlayenvelope(df=SS_out, p=c("trend","rate"))

## exponential transformation
overlayenvelope(df=SS_out, p="cycle_s", transform="exp",
                ylab="exp transform")
overlayenvelope(df=SS_out, p="cycle_s", transform="exp",
                ylab="exp transform", log="y")

[Package jagshelper version 0.2.3 Index]