Group: | Statistical Data Analysis |
Topic: | Nonparametric Methods |
See also: | isoreg sknn rmed l1line lowess |
Function: | sker | |
Description: |
sker computes a direct kernel estimate without binning from scatter plot data.
|
Usage: | z = sker (x, h, K, y {, xest}) | |
Input: | ||
x | n x p x d1 x ... x dn array | |
h | 1 x p x d1 x ... x dn array (global bandwidth) | |
n x p x d1 x ... x dn array (local bandwidth) | ||
K | text (kernel) | |
y | n x m x d1 x ... x dn array | |
xest | k x p x d1 x ... x dn array | |
Output: | ||
z | k x m x d1 x ... x dn array |
z_i = 1/n sum_{k=1,...,n} K((x_k-z_i)/h_i)/h_i y_i
2. sker works only on sorted data x~y. Before applying sker the data must be previously sorted by x. This is done automatically by the macro "skerreg.xpl" or "skerdens.xpl". If the optional parameter xest is given, the data has to be sorted by the first column. If xest is not given, x will be used as xest !
3. The kernel that you specify must have a support on [-1,1], e.g. you cannot use the gaussian kernel directly. To use the gaussian kernel you an approximation
like K(x) = 1/sqrt(2 pi) exp(-0.5 x^2) I(abs(x)<M). If you transform your data
by u = x/M and the kernel by K_M(x) = exp(-0.5/M^2) exp(-0.5 u^2) I(abs(u)<1)
and the bandwidth you achieve a close approximation to the estimation with
the gaussian kernel.
library("kernel") ; loading the quartic kernel x = 2.*uniform(100)-1 x = sort(x) y = 5*x^2+0.5*normal(100) d = createdisplay(1,1) ; r = sker (x, 0.25, "qua", y) f = sker (x, 0.25, "qua", matrix(100)) mh = r./f ; nadaraya-watson estimator on x show(d, 1, 1, x~y, x~mh) ; continuing using xest xest = 2.*(0:100)/100-1 r = sker (x, 0.25, "qua", y, xest) f = sker (x, 0.25, "qua", matrix(100), xest) mh = r./f ; nadaraya-watson estimator on xest show(d, 1, 1, x~y, xest~mh)
Group: | Statistical Data Analysis |
Topic: | Nonparametric Methods |
See also: | isoreg sknn rmed l1line lowess |