| kernel.fun | R Documentation |
Evaluates the r-th derivative K^{(r)}(x) of a kernel function
K and returns an S4 object of class kfun.
kernel.fun(x = NULL, deriv.order = 0L, kernel = "gaussian", n.grid = 512L)
x |
numeric vector of evaluation points. If |
deriv.order |
non-negative integer: derivative order |
kernel |
character string giving the kernel; one of
|
n.grid |
number of grid points when |
The supported kernels at order r = 0:
Gaussian: K(x)=\frac{1}{\sqrt{2\pi}}e^{-x^2/2},
support (-\infty,+\infty).
Epanechnikov: K(x)=\frac{3}{4}(1-x^2)\mathbf{1}_{|x|\le 1}.
Uniform: K(x)=\frac{1}{2}\mathbf{1}_{|x|\le 1}.
Triangular: K(x)=(1-|x|)\mathbf{1}_{|x|\le 1}.
Biweight: K(x)=\frac{15}{16}(1-x^2)^2\mathbf{1}_{|x|\le 1}.
Triweight: K(x)=\frac{35}{32}(1-x^2)^3\mathbf{1}_{|x|\le 1}.
Tricube: K(x)=\frac{70}{81}(1-|x|^3)^3\mathbf{1}_{|x|\le 1}.
Cosine: K(x)=\frac{\pi}{4}\cos\!\left(\frac{\pi x}{2}\right)\mathbf{1}_{|x|\le 1}.
Silverman: K(x)=\frac{1}{2}e^{-|x|/\sqrt{2}}\sin\!\left(\frac{|x|}{\sqrt{2}}+\frac{\pi}{4}\right),
support (-\infty,+\infty).
Logistic: K(x)=\frac{e^{-x}}{(1+e^{-x})^2}=\frac{1}{4}\mathrm{sech}^2(x/2),
support (-\infty,+\infty).
Pow(s,t): K(x)=c_{s,t}(1-|x|^s)^t\mathbf{1}_{|x|\le 1},
c_{s,t}=s/(2B(1/s,t+1)), given as "pow(s,t)"
(see kernel.pow).
Derivatives are computed analytically via Hermite polynomials (Gaussian,
Silverman), Guidoum polynomials (finite-support kernels), the identity
K^{(r)}=\sigma(1-\sigma)Q_{r+1}(\sigma) with \sigma(x)=1/(1+e^{-x})
(logistic, r \le 20) and exact power expansions (Pow, r \le 16).
An S4 object of class kfun with slots:
xnumeric evaluation grid.
yK^{(r)}(x) values.
kernelkernel name.
deriv.orderderivative order r.
callthe matched call.
Use show() for a text summary and plot() for a ggplot2 graphic.
Arsalane Chouaib Guidoum acguidoum@univ-tam.dz, Amel Henider amel.henider@univ-tam.dz and Iago Giné-Vázquez iago.gin-vaz@protonmail.com
Wand, M. P. and Jones, M. C. (1995). Kernel Smoothing. Chapman and Hall, London.
Silverman, B. W. (1986). Density Estimation for Statistics and Data Analysis. Chapman & Hall/CRC, London.
kernel.conv, kfun,
dkde, h.ucv.
## Gaussian kernel (r = 0)
kf <- kernel.fun(kernel = "gaussian", deriv.order = 0L)
show(kf)
plot(kf)
## First derivative of Epanechnikov kernel
kf2 <- kernel.fun(kernel = "epanechnikov", deriv.order = 1L)
plot(kf2)
## Evaluate at specific points
kf3 <- kernel.fun(x = seq(-2, 2, by = 0.1),
kernel = "biweight", deriv.order = 2L)
## Logistic and Pow(s,t) kernels
plot(kernel.fun(kernel = "logistic", deriv.order = 2L))
plot(kernel.fun(kernel = kernel.pow(1.5, 2.5)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.