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.
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,...)
Called for the side effect of generating images and contours representing quantile in 2D data.
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 values to contour.
Smoothing parameter to pass to kde2d. Can take 1 or 2 arguments for x and optionally y smoothing.
Should an image be generated.
Should contours be overlain.
Should a magbar colour bar be added describing the image levels (doim must also be true for this to appear).
The ngrid to send to kde2d / sm.density to determine the resolution of the smoothing.
Should the output of this function be added to the current plot. If FALSE then a new plot is generated.
Label for x-axis, only used if add=FALSE.
Label for y-axis, only used if add=FALSE.
The colour palette to use for the image (this is also sent to magbar).
Specific quantile contours to add. Default is for 50%, 68% and 95% contours, i.e. these contours contain that perecentage of the data.
The position to use for magbar. See magbar help for more details.
The orientation to use for magbar. See magbar help for more details.
Title to use for magbar.
Control of how far the magbar title is shifted away from its default position.
The x limits to use for the data. Default of NULL calculates 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.
The y limits to use for the data. Default of NULL calculates 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.
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).
Aaron Robotham
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.
magplot
, magaxis
, maglab
, magmap
, magrun
, magbar
if (FALSE) {
temp = cbind(rnorm(1e3),rnorm(1e3))
magcon(temp[,1],temp[,2])
}
Run the code above in your browser using DataLab