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: lplocband Description: Estimates the derivative of a regression function (including the 0th derivative) by local polynomial fits on a grid. This quantlet can be used for univariate or multivariate regression estimation.

Reference(s):
Fan J. and Gijbels I. (1995). Local Polynomial Fitting. In: The Monographs on Statistics and Applied Probability 66. Chapman and Hall.

 Usage: {f,variance}=lplocband(x,y,h,xgrid,OrderDer,p{,RidgeCoef{,Kernel}}) Input: x n x k matrix, the independent variable. y n x 1 vector, the dependent variable h bandwidth which may be local or global. Possible dimensions: - m x k matrix (local bandwidths) - 1 x k vector (global bandwidths) - scalar (global bandwidth) xgrid m x k matrix, grid where you estimate the dependent variable. OrderDer scalar, order of the derivative you want to estimate. This order depends on the dimension of the independent variables. - OrderDer = 0 corresponds always to the function itself - 1 <= OrderDer <= k corresponds to the first derivatives - k < OrderDer <= 2*k corresponds to the non mixed second derivatives - OrderDer > 2*k corresponds to the mixed derivatives p scalar, degree of the polynomials (1<=p<=2). Take care that if you want to estimate second derivatives, p must be equal to 2. RidgeCoef optional scalar representing the Ridge coefficient if ridge regression is desired. Kernel optional string defining the kernel function used. The kernel functions available are Quartic ("Qua"), Epanechnikov ("Epa") and Triangle ("Tri") Output: f m x 1 vector representing the estimated OrderDer-th derivative of E(y|x) at each point on xgrid. variance m x 1 vector containing the estimate of the variance of this estimate divided by sigma2, where sigma2 is the variance of the y's.

Note:
This quantlet is not the fastest but it is the only one which returns an estimate of the variance of the estimates. Moreover, it allows local bandwidths as input. If the number of grid points is larger than 1000, you may use one of the other quantlets available to save computing time.

Example:
```library("smoother")
library("plot")
x = 2.*pi.*(uniform(400,2)-0.5)  ; independent variable
x=sort(x)
m = sum(cos(x),2)                ; true function
e = uniform(400)-0.5             ; error term
xgrid=grid(-3|-3,0.3|0.3,20|20)
result=lplocband(x, m+e, 2~1.5, xgrid, 0, 2)	;global bandwidths
plot(x~(m+e),estimates)
setgopt(plotdisplay,1,1,"title","ROTATE!")

```
Result:
```The local polynomial regression estimate (blue) using the
Quartic kernel, the global bandwidth h=2 and the data are
pictured. (bivariate example)
```

Author: P. Kervella, W. Haerdle, 20020124 license MD*Tech
(C) MD*TECH Method and Data Technologies, 05.02.2006