Learn R Programming

ks (version 1.3.2)

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)

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
x-axis, y-axis limits

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 gridsize is not set to a specific value, then it defaults to 100 grid points in each co-ordinate direction i.e. rep(100, d). Not required to be set if specifying eval.points.

If eval.points is not specified, then the density estimate is automatically computed over a grid whose resolution is controlled by gridsize (a grid is required for plotting).

The parametric discriminant analysers use the code from the MASS library namely lda and qda for linear and quadratic discriminants.

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)
iris.mat <- rbind(iris[,,1], iris[,,2], iris[,,3])
ir <- iris.mat[,c(1,2)]
ir.gr <- iris.mat[,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, gridsize=c(250,250))

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

Run the code above in your browser using DataLab