Learn R Programming

ks (version 1.4.4)

kde: Kernel density estimate for multivariate data

Description

Kernel density estimate for 1- to 6-dimensional data.

Usage

kde(x, H, h, gridsize, supp=3.7, eval.points)

Arguments

Value

  • Kernel density estimate is an object of class kde which is a list with 4 fields
  • xdata points - same as input
  • eval.pointspoints that density estimate is evaluated at
  • estimatedensity estimate at eval.points
  • Hbandwidth matrix (>1-d only) or
  • hscalar bandwidth (1-d only)

Details

For d > 1, the kernel density estimate is computed exactly i.e. binning is not used. For d = 1, the binned estimator from the KernSmooth library is used.

For d = 1, 2, 3, if eval.points is not specified, then the density estimate is automatically computed over a grid whose resolution is controlled by gridsize (default is 101, 51 x 51 and 51 x 51 x 51 respectively).

For d > 3, eval.points must be specified.

References

Wand, M.P. & Jones, M.C. (1995) Kernel Smoothing. Chapman & Hall. London.

See Also

plot.kde

Examples

Run this code
### univariate example
data(unicef)
fhat <- kde(unicef[,1], h=sqrt(944))
fhat <- kde(unicef[,1], H=944) ## same as above

### bivariate example
data(unicef)
H.pi <- Hpi(unicef, nstage=1)
fhat <- kde(unicef, H=H.pi)

### 4-variate example
library(MASS)
data(iris)
ir <- iris[,1:4][iris[,5]=="setosa",]
H.scv <- Hscv(ir)
fhat <- kde(ir, H=H.scv, eval.points=ir)

Run the code above in your browser using DataLab