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: lplocband locpol lpregest lpderest lpregxest lpderxest

Quantlet: EBBS
Description: automatic bandwidth selection for univariate and multivariate local polynomial regression. It also fits a smooth curve to (x,y) using the obtained local bandwidths.

Reference(s):

Usage: {f,band}=EBBS(x,y,xgrid,hgrid,OrderDer,p{,msespan{,nterms{,bandspan{,varest{,Kernel{,J2{,J1}}}}}})
Input:
x n x k matrix, the independent variables.
y n x 1 vector, the dependent variable.
xgrid m x k matrix, grid where you estimate the dependent variable.
hgrid l x 1 vector representing a grid of bandwidths. For each point of xgrid, this algorithm determines the best bandwidth in hgrid. Take care that the first J1 values and the last J2 values are excluded. Moreover, as the data are standardized, the grid is always represented as a vector even if the data are multivariate.
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.
msespan optional scalar, represents the span for smoothing the mse.
nterms optional scalar, number of terms in the bias model. The bias model is: <BR> E(fhat(xh)) = b_0+b_1 h^(p+1)+...+ b_nterms h^(p + nterms)
bandspan optional scalar, bandwidth for smoothing the bandwidth. By default, we do not smooth the bandwidth. If this smoothing is not desired then this parameter should be negative (<= 0).
varest optional m x 1 vector, estimates the variance function at each point of xgrid. If not given, varest is computed in the quantlet by a local polynomial regression of the errors obtained by smoothing the raw data with EBBSmain.
Kernel optional string defining the kernel function used in the local polynomial estimation. The available kernel functions are Quartic ("Qua") (default), Epanechnikov ("Epa") and Triangle ("Tri").
J2 optional scalar, number of bandwidth points to the right used for fitting a curve to estimate bias at one bandwidth.
J1 optional scalar, number of bandwidth points to the left used for fitting a curve to estimate bias at one bandwidth.
Output:
f m x 1 vector containing the estimated OrderDer-th derivative of E(y|x) at each point on xgrid.
band m x 1 vector of bandwidths, entails the bandwidth at each point of xgrid.

Note:

Example:
library("stats")
library("plot")
library("smoother")
x = 4.*pi.*(uniform(400)-0.5)   ; independent variable
x=sort(x)
m = cos(x)                      ; true function
e = uniform(400)-0.5            ; error term
xgrid=grid(-6,0.3,40)
hgrid=grid(0.05,0.1,30)
p=2
OrderDer=0  ;OrderDer=1 for the estimation of the first derivative
;OrderDer=2 for the estimation of the second derivative
msespan=4
result=EBBS(x, m+e, xgrid, hgrid, OrderDer, p, msespan)
estimates=setmask((xgrid~result.f) , "line","blue")
TrueFunction  = setmask((x~m) , "line","black","thin")
plot(x~(m+e),TrueFunction,estimates)

Result:
The local polynomial regression estimate (blue) using
Quartic kernel, the local bandwidths obtained by EBBS
and the data are pictured (univariate example).
If you would like to get the bandwidths, just type
"result.band".



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