Learn R Programming

ks (version 1.3.5)

kda.kde, pda.pde: Density estimates for kernel and parametric discriminant analysis for multivariate data

Description

Density estimates for kernel and parametric discriminant analysis for 2- to 6-dimensional data.

Usage

kda.kde(x, x.group, Hs, gridsize, supp=3.7, eval.points=NULL)
pda.pde(x, x.group, gridsize, type="quad", xlim, ylim, zlim)

Arguments

x
matrix of training data values
x.group
vector of group labels for training data
Hs
(stacked) matrix of bandwidth matrices
gridsize
vector of number of grid points
supp
effective support for standard normal is [-supp, supp]
eval.points
points that density estimate is evaluated at
type
"line" = linear discriminant, "quad" = quadratic discriminant
xlim, ylim, zlim
x-axis, y-axis, z-axis limits (used only for plotting)

Value

  • Density estimate for discriminant analysis is an object of class dade which is a list with 6 fields
  • xdata points - same as input
  • eval.pointspoints that density estimate is evaluated at
  • estimatedensity estimate at eval.points
  • Hbandwidth matrices
  • prior.probsample proportions of each group
  • typeone of "kernel", "linear", "quadratic" indicating the type of discriminant analyser used.

Details

The kernel density estimate is based on kde. If eval.points=NULL (default) then the density estimate is automatically computed over a grid whose resolution is controlled by gridsize (default is 100 in each co-ordinate direction).

The linear and quadratic discriminant analysers are based on lda and qda from the MASS library. If xlim and ylim are not specified then they default to be 10% bigger than the range of the data values.

References

Mardia, K.V., Kent, J.T. & Bibby J.M. (1979) Multivariate Analysis. Academic Press. London. Simonoff, J. S., (1996) Smoothing Methods in Statistics, Springer-Verlag. New York. Venables, W.N. & Ripley, B.D. (1997) Modern Applied Statistics with S-PLUS, Springer-Verlag. New York.

See Also

plot.dade, pda, kda, kde

Examples

Run this code
library(MASS)
data(iris)
ir <- iris[,c(1,2)]
ir.gr <- iris[,5]

H <- Hkda(ir, ir.gr, bw="plugin", pre="scale")
kda.gr <- kda(ir, ir.gr, H, ir)
fhat <- kda.kde(ir, ir.gr, H)

qda.gr <- pda(ir, ir.gr, ir, type="quad")
qda.fhat <- pda.pde(ir, ir.gr)

Run the code above in your browser using DataLab