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

 Quantlet: locpolex Description: computes the local polynomial estimator with an arbitrary kernel.

 Usage: {ab,e} = locpolex(x,xg,y,h{,kernfunc,omitx,z,zg}) Input: x n x d matrix of explanatory variables xg m x d matrix of grid points at which the estimation will be done y n x 1 vector representing the dependent variable h scalar or d x 1 vector representing the bandwidth(s); if h is a scalar, the same bandwidth is used across all dimensions of x kernfunc optional string, it contains the name of a function that computes a kernel (e.g., a function from library "kernel"); if kernfunc is omitted or empty, the Gaussian kernel function "gau" is used omitx optional scalar, if non-zero, then the point at which we just compute the local linear approximation is itself excluded from the computation; this option is only usable if x == xg and it is disabled (omitx == 0) by default z optional n x d1 matrix, it can contain alternative data points that are then used in computing the kernel distances instead of x (e.g., z can be a subset of x); it can be used only together with zg; by default, z = x zg optional m x d1 matrix, it can contain alternative data points that are then used in computing the kernel distances instead of xg (e.g., z can be a subset of x); it can be used only together with z; by default, zg = xg Output: ab m x (d+1) matrix, the regression function (the first column) and its first d derivatives at xg e n x 1 vector of regression residuals

Note:
There are two main differences between the function locpol and the quantlet locpolex.

1) It is possible to include only linear terms in locpolex, not quadratic ones.

2) Locpolex is more flexible: a user can choose a kernel function and can also use kernel distances computed from observations different from x (e.g., kernel is applied on a subspace of data x). Moreover, regression residuals are computed. These features are used, for example, by MIregest quantlet.

Example:
```library("smoother")
library("plot")
; generate data
n   = 200
x  = sort(2*uniform(n))
y  = 1.5*cos(x^3) + 0.2 * normal(n)
h = 0.1
; estimation with gaussian and quartic kernel
mh1 = locpolex(x,x,y, h)
mh2 = locpolex(x,x,y, h, "qua")
; plot
data = setmask(x ~ y, "small")
lp1 = setmask(x ~ mh1.ab[,1], "line", "thin", "red")
lp2 = setmask(x ~ mh2.ab[,1], "line", "thin", "blue")
plot(data, lp1, lp2)

```
Result:
```A display showing local polynomial regression with the
Gaussian (red line) and the quartic (blue line) kernels.
```

Author: P. Cizek, 20020419
(C) MD*TECH Method and Data Technologies, 05.02.2006