Plot credible intervals as shaded boxplots using hdr.boxplot

Description

This function is essentially hdr.boxplot but it more easily works with matrices of data, where each column is a different variable of interest. It has some limitations though....

Usage

1
2
3
4
5
siberDensityPlot(dat, probs = c(95, 75, 50), xlab = "Group",
  ylab = "Value", xticklabels = NULL, yticklabels = NULL,
  clr = grDevices::gray((9:1)/10), scl = 1, xspc = 0.5, prn = F,
  ct = "mode", ylims = NULL, lbound = -Inf, ubound = Inf, main = "",
  ylab.line = 2, ...)

Arguments

dat

a matrix of data for which density region boxplots will be constructed and plotted for each column.

probs

a vector of credible intervals to represent as box edges. Defaults to c(95, 75, 50).

xlab

a string for the x-axis label. Defaults to "Group".

ylab

a string fo the y-axis label. Defaults to "Value".

xticklabels

a vector of strings to override the x-axis tick labels.

yticklabels

a vector of strings to override the y-axis tick labels.

clr

a vector of colours to use for shading each of the box regions. Defaults to greyscale grDevices::gray((9:1)/10).

scl

a scalar multiplier to scale the box widths. Defaults to 1.

xspc

a scalar determining the amount of spacing between each box. Defaults to 0.5.

prn

a logical value determining whether summary statisics of each column should be printed to screen prn = TRUE or suppressed as per default prn = FALSE.

ct

a string of either c("mode", "mean", "median") which determines which measure of central tendancy will be plotted as a point in the middle of the boxes. Defaults to "mode".

ylims

a vector of length two, specifying the lower and upper limits for the y-axis. Defaults to NULL which inspects the data for appropriate limits.

lbound

a lower boundary to specify on the distribution to avoid the density kernel estimating values beyond that which can be expecte a priori. Useful for example when plotting dietary proportions which must lie in the interval 0 <= Y <= 1. Defaults to -Inf

ubound

an upper boundary to specify on the distribution to avoid the density kernel estimating values beyond that which can be expecte a priori. Useful for example when plotting dietary proportions which must lie in the interval 0 <= Y <= 1. Defaults to +Inf.

main

a title for the figure. Defaults to blank.

ylab.line

a postive scalar indicating the line spacing for rendering the y-axis label. This is included as using the permille symbol has a tendancy to push the axis label off the plotting window margins. See the line option in axis for more details as ylab.line passes to this.

...

further graphical parameters for passing to plot

Value

A new figure window.

Warning

: This function will not currently recognise and plot multimodal distributions, unlike hdr.boxplot. You should take care, and plot basic histograms of each variable (column in the object you are passing) to siardensityplot and check that they are indeed unimodal as expected.

Examples

1
2
Y <- matrix(stats::rnorm(1000), 250, 4)
siberDensityPlot(Y)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.