contourLevels {ks} | R Documentation |
Contour levels for kde
and kda.kde
objects.
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, ...)
x |
an object of class kde or kda.kde |
prob |
vector of probabilities corresponding to highest density regions |
cont |
vector of percentages which correspond to the complement
of prob |
nlevels |
number of pretty contour levels |
... |
other parameters for contour |
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.
For kde
objects, returns vector of heights. For kda.kde
objects, returns a list of vectors, one for each training group.
## 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))