get_levels2d: Compute contours encircling specified masses.

Description Usage Arguments Details Value Notes See Also Examples

View source: R/plot_contour.R

Description

get_levels2d returns density levels enclosing specified masses.

Usage

1
get_levels2d(img, prob = 0.95)

Arguments

img

(list) containing three components: x, y, z

prob

(vector) probability masses at which to define levels.

Details

Function to compute the density levels at which to draw contour lines in order to enclose a fraction prob of the mass.

Value

Vector of the density levels (one for each element of prob). If prob = 0.95 then a contour a level contains 95% of the mass.

Notes

The input img should be a list with three components: img$z is a vector of nx evenly spaced x positions, img$y is a vector of ny evenly spaced y position, img$z is an nx*ny array of z values at the (x, y) coordinates.

See Also

chain_convergence, contour_matrix

Examples

1
2
3
4
5
n <- 1000
x <- rnorm(n)
y <- x + rnorm(n)
img <- hist2d(x, y, npix = 11)
get_levels2d(img, prob = c(0.5, 0.9))

svdataman/tonic documentation built on Aug. 2, 2019, 3:21 p.m.