Learn R Programming

ks (version 1.5.10)

contourLevels: Contour levels for kde and kda.kde objects

Description

Contour levels for kde and kda.kde objects.

Usage

contourLevels(x, ...)

## S3 method for class 'kde': contourLevels(x, prob, cont, nlevels=5, ...)

## S3 method for class 'kda.kde': contourLevels(x, prob, cont, nlevels=5, ...)

Arguments

Value

  • For kde objects, returns vector of heights. For kda.kde objects, returns a list of vectors, one for each training group.

Details

The most straightfoward is to specify prob. Heights of the corresponding highest density region with probability prob are computed.

The cont parameter here is consistent with cont parameter from plot.kde and plot.kda.kde i.e. cont = (1 - prob)*100%.

If both prob and cont are missing then a pretty set of nlevels contours are computed.

See Also

contour, contourLines

Examples

Run this code
## kde 
x <- rmvnorm.mixt(n=100, mus=c(0,0), Sigmas=diag(2), props=1)
Hx <- Hpi(x)
fhatx <- kde(x=x, H=Hx)
lev1 <- contourLevels(fhatx, prob=c(0.25, 0.5, 0.75))
lev2 <- contourLevels(fhatx, cont=c(75, 50, 25))      ## lev1 == lev2

## kda.kde
library(MASS)
data(iris)
ir <- iris[,1]
ir.gr <- iris[,5]
kda.fhat <- kda.kde(ir, ir.gr, hs=sqrt(c(0.01, 0.04, 0.07)))
contourLevels(kda.fhat, prob=c(0.25, 0.5, 0.75))

Run the code above in your browser using DataLab