Learn R Programming

ks (version 1.4.4)

plot.kda.kde: Kernel discriminant analysis plot for 1- to 3-dimensional data

Description

Kernel discriminant analysis plot for 1- to 3-dimensional data.

Usage

## univariate
## S3 method for class 'kda.kde':
plot(x, y, y.group, prior.prob=NULL, xlim, ylim,
    xlab="x", ylab="Weighted density function", drawpoints=TRUE,
    lty, lcol, col, ptcol, ...)

## bivariate ## S3 method for class 'kda.kde': plot(x, y, y.group, prior.prob=NULL, cont=c(25,50,75), ncont=NULL, xlim, ylim, xlab="x", ylab="y", drawpoints=TRUE, drawlabels=TRUE, cex=1, pch, lty, col, lcol, ptcol, ...)

## trivariate ## S3 method for class 'kda.kde': plot(x, y, y.group, prior.prob=NULL, cont=c(25,50), colors, alphavec, origin=c(0,0,0), endpts, xlab="x", ylab="y", zlab="z", drawpoints=TRUE, size=3, ptcol, ...)

Arguments

Value

  • Plot of 1-d and 2-d density estimates for discriminant analysis is sent to graphics window. Plot for 3-d is sent to RGL window.

synopsis

## S3 method for class 'kda.kde': plot(x, y, y.group, ...)

Details

If prior.prob is set to a particular value then this is used. The default is NULL which means that the sample proportions are used.

The object x contains the training data and its group labels. If y and y.group are missing then the training data points are plotted. Otherwise, the test data y are plotted.

-- For 1-d plots: The partition induced by the discriminant analysis is plotted as rug plot (with the ticks inside the axes). If drawpoints=TRUE then the data points are plotted as a rug plot with the ticks outside the axes, their colour is controlled by ptcol. -- For 2-d plots: If display="part" then a partition induced by the discriminant analysis is also plotted. If this is not desired, set display="". Its colours are controlled by col (the default is heat.colors).

The plotting symbols are set by pch and the colour by ptcol. Unlike plot.kde, the contour plots are automatically added to the plot. Default contours are cont=c(25,50,75). The line types are set by lty. cont and ncont control the number of level curves (only one of these needs to be set).

-- For 3-d plots: Default contours are cont=c(25,50). Colors are set one per group - default is heat.colors. The transparency of each contour (within each group) is alphavec. Default range is 0.1 to 0.5. origin is the point where the three axes meet. endpts is the vector of the maximum axis values to be plotted. Default endpts is the maxima for the plotting grid from x.

References

Bowman, A.W. & Azzalini, A. (1997) Applied Smoothing Techniques for Data Analysis. Clarendon Press. Oxford. Simonoff, J. S., (1996) Smoothing Methods in Statistics. Springer-Verlag. New York.

See Also

kda.kde, kda

Examples

Run this code
library(MASS)
data(iris)

xlab <- "Sepal length (mm)"
ylab <- "Sepal width (mm)"
xlim <- c(4,8)
ylim <- c(2,4.5)

## univariate example
ir <- iris[,1]
ir.gr <- iris[,5]

kda.fhat <- kda.kde(ir, ir.gr, hs=sqrt(c(0.01, 0.04, 0.07)))
plot(kda.fhat, xlab=xlab, ptcol=1:3)

## bivariate example
ir <- iris[,1:2]
ir.gr <- iris[,5]
H <- Hkda(ir, ir.gr, bw="plugin", pre="scale")
kda.fhat <- kda.kde(ir, ir.gr, Hs=H)

plot(kda.fhat, cont=0, xlab=xlab, ylab=ylab, xlim=xlim, ylim=ylim)
plot(kda.fhat, ncont=6, xlab=xlab, ylab=ylab, xlim=xlim, ylim=ylim,
     col=c("transparent", "grey", "#8f8f8f"), drawlabels=FALSE,
     pch=c(1,5,10))


## trivariate example
ir <- iris[,1:3]
ir.gr <- iris[,5] 
H <- Hkda(ir, ir.gr, bw="plugin", pre="scale")
kda.fhat <- kda.kde(ir, ir.gr, Hs=H)
plot(kda.fhat)
   ## colour indicates species, transparency indicates density heights

Run the code above in your browser using DataLab