kern | R Documentation |
Different type of kernel functions.
kern(u, type='epk')
u |
a numeric vector, evluated points in kernel funciton. |
type |
a optional character string, specify the type of used kernel functionand support 'epk', 'biweight', 'triangle', 'guassian', 'triweight', 'tricube', 'cosine', 'uniform' in current version, defualt as 'epk'. |
Note that K(u_i)=K(X_i-x_0) where u = (X_1-x_0, ..., X_n-x_0) and K_h(u_i)=1/h*K((X_i-x_0)/h) where h is bandwidth.
Return a numeric vector with length equal to 'u'.
Liu Wei
KernSmooth package
library(graphics)
u <- seq(-1,1,by=0.01)
(Ku <- kern(u))
plot(u, Ku, type='l')
# guassian kernel
plot(u, kern(u, type='gaussian'), type ='l')
# cosine kernel
plot(u, Ku <- kern(u, type='cosine'), type ='l')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.