Learn R Programming

kedd (version 1.0.4)

kernel.fun: Derivatives of Kernel Function

Description

The (S3) generic function kernel.fun computes the r'th derivative for kernel density.

Usage

kernel.fun(x, ...)
# S3 method for default
kernel.fun(x = NULL, deriv.order = 0, kernel = c("gaussian","epanechnikov", 
            "uniform", "triangular", "triweight", "tricube", 
            "biweight", "cosine", "silverman"), ...)

Value

kernel

name of kernel to use.

deriv.order

the derivative order to use.

x

the n coordinates of the points where the derivative of kernel function is evaluated.

kx

the kernel derivative values.

Arguments

x

points at which the derivative of kernel function is to be evaluated.

deriv.order

derivative order (scalar).

kernel

a character string giving the smoothing kernel to be used, with default "gaussian".

...

further arguments for (non-default) methods.

Author

Arsalane Chouaib Guidoum acguidoum@usthb.dz

Details

We give a short survey of some kernels functions \(K(x;r)\); where \(r\) is derivative order,

  • Gaussian: \(K(x;\infty) =\frac{1}{\sqrt{2\pi}}\exp\left(-\frac{x^{2}}{2}\right)1_{]-\infty,+\infty[}\)

  • Epanechnikov: \(K(x;2)=\frac{3}{4}(1-x^{2})1_{(|x| \leq 1)}\)

  • uniform (rectangular): \(K(x;0)=\frac{1}{2}1_{(|x| \leq 1)}\)

  • triangular: \(K(x;1)=(1-|x|)1_{(|x| \leq 1)}\)

  • triweight: \(K(x;6)=\frac{35}{32}(1-x^{2})^{3} 1_{(|x| \leq 1)}\)

  • tricube: \(K(x;9)=\frac{70}{81}(1-|x|^{3})^{3} 1_{(|x| \leq 1)}\)

  • biweight: \(K(x;4)=\frac{15}{16}(1-x^{2})^{2} 1_{(|x| \leq 1)}\)

  • cosine: \(K(x;\infty)=\frac{\pi}{4}\cos\left(\frac{\pi}{2}x\right) 1_{(|x| \leq 1)}\)

  • Silverman: \(K(x;r \bmod 8)=\frac{1}{2}\exp\left(-\frac{|x|}{\sqrt{2}}\right)\sin\left(\frac{|x|}{\sqrt{2}}+\frac{\pi}{4}\right)1_{]-\infty,+\infty[}\)

The r'th derivative for kernel function \(K(x)\) is written: $$K^{(r)}(x) = \frac{d^{r}}{d x^{r}} K(x)$$ for \(r = 0, 1, 2, \dots\)
The r'th derivative of the Gaussian kernel \(K(x)\) is given by: $$K^{(r)}(x) = (-1)^{r} H_{r}(x) K(x)$$ where \(H_{r}(x)\) is the r'th Hermite polynomial. This polynomials are set of orthogonal polynomials, for more details see, hermite.h.polynomials in package orthopolynom.

References

Jones, M. C. (1992). Differences and derivatives in kernel estimation. Metrika, 39, 335--340.

Olver, F. W., Lozier, D. W., Boisvert, R. F. and Clark, C. W. (2010). NIST Handbook of Mathematical Functions. Cambridge University Press, New York, USA.

Silverman, B. W. (1986). Density Estimation for Statistics and Data Analysis. Chapman & Hall/CRC. London.

See Also

plot.kernel.fun, deriv and D in package "stats" for symbolic and algorithmic derivatives of simple expressions.

Examples

Run this code
kernels <- eval(formals(kernel.fun.default)$kernel)
kernels

## gaussian
kernel.fun(x = 0,kernel=kernels[1],deriv.order=0)
kernel.fun(x = 0,kernel=kernels[1],deriv.order=1)

## silverman
kernel.fun(x = 0,kernel=kernels[9],deriv.order=0)
kernel.fun(x = 0,kernel=kernels[9],deriv.order=1)

Run the code above in your browser using DataLab