Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

 Group: Statistical Data Analysis Topic: Nonparametric Methods See also: isoreg sknn rmed l1line lowess ngau

 Function: sker Description: sker computes a direct kernel estimate without binning from scatter plot data.

Reference(s):
Haerdle, W. (1990). "Applied Nonparametric Regression", Cambridge University Press.

 Usage: z = sker (x, h, K, y {, xest}) Input: x n x p x d1 x ... x dn array representing the data of the explanatory variable h 1 x p x d1 x ... x dn array, global bandwidth, or k x p x d1 x ... x dn array, local bandwidth, the smoothing parameter K text (specifies the kernel function which should be used) y n x m x d1 x ... x dn array representing the data of the dependent variable xest k x p x d1 x ... x dn array (optional), specifies the point of estimation. If this parameter is not given the values of x will be used for xest. Output: z k x m x d1 x ... x dn array

Note:
sker estimates:

z_i = 1/n sum_{j=1,...,n} K((x_j-xest_i)/h_i)/h_i y_j

1. 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 quantlet "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 !

2. The kernel that you specify must have its support on [-1,1], i.e. you cannot use the Gaussian kernel directly. To use the Gaussian kernel you have to use 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, the kernel by K_M(x) = exp(-0.5/M^2) exp(-0.5 u^2) I(abs(u)<1) (see the kernel ngau) and the bandwidth then you achieve a close approximation to the estimation with the Gaussian kernel.

Example:
```library("kernel")        ; loading the quartic kernel
x = 2.*uniform(100)-1
x = sort(x)
y = 5*x^2+0.5*normal(100)
d = createdisplay(2,1)
r = sker(x, 0.25, "qua", y)
f = sker(x, 0.25, "qua", matrix(100))
mh = r./f                ; nadaraya-watson estimator on x
mh = x~mh
show(d, 1, 1, x~y, 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
mh = xest~mh
```n/a