plot.dade {ks} | R Documentation |
Density estimate and partition classes plot for 2- and 3-dimensional for kernel, linear and quadratic discriminant analysis
## bivariate ## S3 method for class 'dade': plot(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, ptcol, ...) ## trivariate ## S3 method for class 'dade': plot(x, y, y.group, prior.prob=NULL, display="rgl", cont=c(25,50), colors, alphavec, origin=c(0,0,0), endpts, xlabs="x", ylabs="y", zlabs="z", drawpoints=TRUE, size=3, ptcol, ...)
x |
an object of class dade i.e. output from
kda.kde or pda.pde |
display |
"part" = include plot of partition classes, "" = don't plot partition i.e. density estimates only) |
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 |
cex,pch,lty,xlim,ylim,xlabs,ylabs,zlabs |
usual graphics parameters |
drawlabels |
if TRUE then draw contour labels |
col |
vector of colours for partition classes |
ptcol |
vector of colours for data points of each group |
lcol |
vector of colours for contour lines of density estimates |
colors |
vector of colours for contours of density estimates (3-d plot) |
origin |
origin vector (3-d plot) |
endpts |
vector of end points for each of the 3 axes (3-d plot) |
alphavec |
vector of transparency values - one for each contour (3-d plot) |
drawpoints |
if TRUE then data points are plotted (3-d plot) |
size |
size and of plotting symbol (3-d plot) |
... |
other graphics parameters |
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.
The plotting symbols are set by pch
(the default is 1 to
nu), one for each group, where nu is the
number of groups, and the colour 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
).
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
(the default
is 1 to nu). Also,
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 is
seq(0.1, 0.5, length(cont))
. 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
(automatically generated by
kde
).
Plot of 2-d density estimates (and partition) for discriminant analysis is
sent to graphics window. Plot for 3-d is generated by the
misc3d
and rgl
libraries and is sent to RGL window.
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.
## bivariate example library(MASS) data(iris) ir <- iris[,c(1,2)] ir.gr <- iris[,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) 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) ## trivariate example ir <- iris[,1:3] ir.gr <- iris[,5] H <- Hkda(ir, ir.gr, bw="plugin", pre="scale") fhat <- kda.kde(ir, ir.gr, H) plot(fhat, cont=c(25,50)) ## colour indicates species, transparency indicates density heights qda.fhat <- pda.pde(ir, ir.gr, type="quad") plot(qda.fhat, cont=c(25,50))