kde2dQuantile: Two-Dimensional Kernel Density Estimation Quantiles

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/kde2dQuantile.R

Description

Produces sample quantiles from a two-dimensional kernel density estimation corresponding to the given probabilities.

Usage

1
kde2dQuantile(d, X, Y, probs = .05, ...)

Arguments

d

an object returnd by kde2d.

X

numeric vector of x coordinate of data whose sample quantiles are wanted.

Y

numeric vector of y coordinate of data whose sample quantiles are wanted.

probs

numeric vector of probabilities.

...

additional arguments passed to quantile.

Details

Useful for contour plots of 2-dimensional KDE quantiles.

Value

A vector of quantiles corresponding to the given probabilities.

Author(s)

Antoine Filipovic Pierucc

See Also

kde2d, contour.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
a <- rnorm(10)
b <- rnorm(10)
# an ugly imitation of a kde2d estimate
# since we don't want to load MASS just for an exemple
f1 <- structure(list(x = c(-3.1, -1.575, -0.05, 1.475, 3),
                     y = c(-3.213, -1.591, 0.032, 1.654, 3.276),
                     z = structure(c(0, 0, 0.003, 0, 0, 0,
                                     0.009, 0.05, 0.015,
                                     0, 0.001, 0.05, 0.152,
                                     0.052, 0.003, 0, 0.01,
                                     0.039, 0.028, 0.001, 0,
                                     0, 0.001, 0, 0),
                                   .Dim = c(5L, 5L))),
                     .Names = c("x", "y", "z"))

quant <- kde2dQuantile(f1, a, b, c(.05, .5))

contour(f1, levels = quant, labels = names(quant))

Example output



rmngb documentation built on May 29, 2017, 9:22 p.m.

Related to kde2dQuantile in rmngb...