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

Library: smoother
See also: lpregest lregestp lpregxest lregxestp lpderest lpderxest

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):

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:

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
estimates=setmask((xgrid~result.f) , "surface","blue")
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