magicaxis (version 2.0.10)

magcon: 2D quantile images and contours

Description

This function generates pretty images and contours that reflect the 2D quantile levels of the data. This means the user can immediately assess the 2D regime that contains an arbitrary percentage of the data. This function was designed particularly with the output of MCMC posteriors in mind, where visualising the location of the 68% and 95% 2D quantiles for covariant parameters is a necessary part of the post MCMC analysis.

Usage

magcon(x, y, h, doim = TRUE, docon = TRUE, dobar = TRUE, ngrid = 100, add = FALSE,
xlab = '', ylab = '', imcol = c(NA,rev(rainbow(1000, start = 0, end = 2/3))),
conlevels = c(0.5, pnorm(1) - pnorm(-1), 0.95), barposition = "topright",
barorient = "v",bartitle = "Contained %", bartitleshift = 0, xlim = NULL, ylim = NULL,
weights = NULL,...)

Arguments

x

x values to contour. If x is a two (or more) column matrix or data.frame and y is missing as an argument, then the first column is used for x and the second column for y.

y

y values to contour.

h

Smoothing parameter to pass to kde2d. Can take 1 or 2 arguments for x and optionally y smoothing.

doim

Should an image be generated.

docon

Should contours be overlain.

dobar

Should a magbar colour bar be added describing the image levels (doim must also be true for this to appear).

ngrid

The ngrid to send to kde2d / sm.density to determine the resolution of the smoothing.

add

Should the output of this function be added to the current plot. If FALSE then a new plot is generated.

xlab

Label for x-axis, only used if add=FALSE.

ylab

Label for y-axis, only used if add=FALSE.

imcol

The colour palette to use for the image (this is also sent to magbar).

conlevels

Specific quantile contours to add. Default is for 50%, 68% and 95% contours, i.e. these contours contain that perecentage of the data.

barposition

The position to use for magbar. See magbar help for more details.

barorient

The orientation to use for magbar. See magbar help for more details.

bartitle

Title to use for magbar.

bartitleshift

Control of how far the magbar title is shifted away from its default position.

xlim

The x limits to use for the data. Default of NULL caculates the range based on the provided x data vector. Data will be clipped between the extremes given. If xlim[1]>xlim[2] plotted axes will be flipped compared to default.

ylim

The y limits to use for the data. Default of NULL caculates the range based on the provided y data vector. Data will be clipped between the extremes given. If ylim[1]>ylim[2] plotted axes will be flipped compared to default.

weights

A vector of weights to pass onto sm.density (that does the 2D density estimate). This must be the same length as the x and y vectors if specified.

Other arguments to pass to the contour function, e.g. lty=c(2,1,3).

Value

Called for the side effect of generating images and contours representing quantile in 2D data.

Details

This function is particularly designed to assess the output for MCMC posteriors since it highlights the confidence regimes quite clearly. More generally it can show the quantile distributions for any 2D data.

See Also

magplot,magaxis,maglab,magmap,magrun,magbar

Examples

Run this code
# NOT RUN {
temp=cbind(rnorm(1e3),rnorm(1e3))
magcon(temp[,1],temp[,2])
# }

Run the code above in your browser using DataCamp Workspace