plotdens {jagshelper}R Documentation

Plot kernel densities of single parameter nodes

Description

Produces a kernel density plot of a single or multiple parameter nodes (overlayed).

Input can be of multiple possible formats: either a single or list of output objects from jagsUI with an associated vector of parameter names, or a vector or data.frame of posterior samples.

Usage

plotdens(
  df,
  p = NULL,
  exact = FALSE,
  add = FALSE,
  col = NULL,
  shade = TRUE,
  lwd = 2,
  minCI = 0.99,
  legend = TRUE,
  legendpos = "topleft",
  legendnames = NULL,
  main = NULL,
  xlab = "",
  ylab = "Density",
  ...
)

Arguments

df

Input object for plotting. See examples below.

p

Vector of parameter names, if df is given as a single or list of output objects from jagsUI

exact

Whether the ⁠p=⁠ argument should match the parameter name exactly. See jags_df for details.

add

Whether to add to an existing plot (TRUE) or produce a new plot. Defaults to FALSE.

col

Vector of colors for plotting. If the default (NULL) is accepted, colors will be automatically selected.

shade

Whether to shade the regions below the kernel density curve(s). Defaults to TRUE.

lwd

Line width for kernel density curves. Defaults to 2. Note: setting this to 0 (or FALSE) will suppress lines.

minCI

Minimum CI width to include for all density curves. Defaults to 99%.

legend

Whether to plot a legend. Defaults to TRUE.

legendpos

Position for automatic legend. Defaults to "topleft".

legendnames

Names for legend

main

Plot title. Defaults to "".

xlab

X-axis label. Defaults to "".

ylab

Y-axis label. Defaults to "Density".

...

Optional plotting arguments

Value

NULL

Author(s)

Matt Tyers

See Also

comparedens, comparecat, comparepriors

Examples

## jagsUI object with a single parameter
plotdens(asdf_jags_out, p="b1")

## jagsUI object with multiple nodes of a parameter
plotdens(asdf_jags_out, p="a")

## jagsUI object with multiple parameter nodes
plotdens(asdf_jags_out, p=c("a[1]","a[2]","a[3]"))

## data.frame with multiple columns
plotdens(jags_df(asdf_jags_out, p="a"))

## list of jagsUI objects with a single parameter name
plotdens(list(asdf_jags_out,asdf_jags_out,asdf_jags_out), p="b1")

## list of jagsUI objects with a vector of parameter names
plotdens(list(asdf_jags_out,asdf_jags_out,asdf_jags_out), p=c("a[1]","a[2]","a[3]"))

[Package jagshelper version 0.2.3 Index]