Learn R Programming

ks (version 1.3.2)

plot.dade: Density estimates and partition plot for discriminant analysis for bivariate data

Description

Density estimate plot and partition for bivariate data for kernel, linear and quadratic discriminant analysis

Usage

## S3 method for class 'dade':
plot(x, y, y.group, prior.prob=NULL, display="part", 
       cont=c(25,50,75), ncont=NULL, ...)

Arguments

x
an object of class dade i.e. output from kda.kde or pda.pde
display
include plot of partition classes
y
matrix of test data points
y.group
vector of group labels for test data points
prior.prob
vector of prior probabilities
cont
vector of percentages (of maximum height) for contour level curves
ncont
number of contour level curves
...
other graphics parameters

Value

  • Plot of density estimates (and partition) for discriminant analysis is sent to graphics window.

synopsis

plot.dade(x, y, y.group, prior.prob=NULL, display="part", cont=c(25,50,75), ncont=NULL, xlim, ylim, xlabs="x",ylabs="y", drawlabels=TRUE, cex=1, pch, lty, col, lcol, ...)

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. If display="part" then a partition induced by the discriminant analysis is also plotted. If this is not desired then set display="". Its colours are controlled by col (the default is 2 to $\nu+1$, where $\nu$ is the number of groups). Unlike plot.kde, the contour plots are automatically added to the plot. The line types are set by lty (the default is 1 to $\nu$). Also, cont and ncont control the number of level curves (only one of these needs to be set).

The object fhat 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. The plotting symbols are set by pch (the default is 1 to $\nu$), one for each group.

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, pda.pde, kda, pda

Examples

Run this code
library(MASS)
data(iris)
iris.mat <- rbind(iris[,,1], iris[,,2], iris[,,3])
ir <- iris.mat[,c(1,2)]
ir.gr <- iris.mat[,5]
xlab <- "Sepal length (mm)"
ylab <- "Sepal width (mm)"
xlim <- c(4,8)
ylim <- c(2,4.5)

H <- Hkda(ir, ir.gr, bw="plugin", pre="scale")
fhat <- kda.kde(ir, ir.gr, H, gridsize=c(250,250))
lda.fhat <- pda.pde(ir, ir.gr, type="line")
qda.fhat <- pda.pde(ir, ir.gr, type="quad")

layout(rbind(c(1,2), c(3,4)))
plot(fhat, cont=0, xlab=xlab, ylab=ylab, xlim=xlim, ylim=ylim, 
    pch=c(1,5,10))
plot(fhat, ncont=6, xlab=xlab, ylab=ylab, xlim=xlim, ylim=ylim,
     col=c("transparent", "grey", "#8f8f8f"), drawlabels=FALSE)
plot(lda.fhat, ncont=6, xlim=xlim, ylim=ylim, xlab=xlab, ylab=ylab, 
     disp="")
plot(qda.fhat, ncont=6, xlim=xlim, ylim=ylim,  xlab=xlab, ylab=ylab, 
     lty=c(2,5,3))
layout(1)

Run the code above in your browser using DataLab