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: EBBSmain Description: automatic bandwidth selection for univariate and multivariate local polynomial regression. It also fits a smooth curve to (x,y) using the resulting local bandwidths.

Reference(s):
Ruppert, D. (1997). Empirical-bias Bandwidths for Local Polynomial Nonparametric Regression and Density Estimation. Journal of the American Statistical Association 92: pp. 1049-1062.

 Usage: {f,band}=EBBSmain(x,y,xgrid,hgrid,OrderDer,p,type,varest{,msespan{,nterms{,bandspan{,Kernel{,J2{,J1{,RidgeCoef}}}}}}}) 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, 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 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, then p must be equal to 2. type scalar, type of variance estimation: - 1 means that "varest" contains a variance estimation of the response for each target point in xgrid. - 2 means that the algorithm will use "coef=(sqrt(var(y))/mean(y))^2" to estimate the variance part in the MSE. Please refer to Ruppert's article. varest if type==1, it is m x 1 vector, estimates of the variance function at each point of xgrid. if type==2, it is scalar (e.g., 1) and it has in this case no influence on the algorithm. msespan optional scalar, number of points used to smooth the estimate of MSE. If msespan is equal to 0 then the entire grid is used and all points have the same weights. This yields an optimal global bandwidth. Setting msespan to 0 is advocated for small sample size. nterms optional scalar, number of terms in the bias model The bias model is 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 scalar, estimate of the variance function at each point of xgrid. Kernel optional string. kernel function used in the local polynomial estimation. The kernel functions available 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 representing 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:
The main difference to EBBS is that you have to give an estimation of the variance of the response as input parameter.

Example:
```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=0
;Here, we will estimate the conditional variance of the response
hTemp=lpregrot(x~(m+e))
resultTemp=lplocband(x,m+e,hTemp,x,0,1)
squareresid=((m+e)-resultTemp.f).^2
hTemp=lpregrot(x~squareresid)
Temp=lplocband(x,squareresid,hTemp,xgrid,0,1)
varest=Temp.f
result=EBBSmain(x, m+e, xgrid, hgrid, OrderDer, p, 1,varest,msespan)
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