envelope: Envelope plot

View source: R/envelope.R

envelopeR Documentation

Envelope plot

Description

Envelope plot of the posterior densities of a vector of parameter nodes, in which the sequential order of nodes is important, such as a time series.

This produces a plot of overlayed shaded strips, each corresponding to a given interval width (defaults to 50 percent and 95 percent), with an overlayed median line.

Usage

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

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.

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

ci

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

col

Color for plotting

add

Whether to add to existing plot

dark

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

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.

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

overlayenvelope, caterpillar

Examples

## usage with input data.frame
trend <- jags_df(SS_out, p="trend")
envelope(trend, x=SS_data$x)

## usage with jagsUI object
envelope(SS_out, p="trend")

## usage with 2-d jagsUI object
envelope(SS_out, p="cycle_s", column=1, main="cycle")
envelope(SS_out, p="cycle_s", column=2, col=2, add=TRUE)  ## overlay

## scale transformation
envelope(SS_out, p="trend", transform="exp", ylab="exp transform")
envelope(SS_out, p="trend", transform="exp", ylab="exp transform", log="y")

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