Library: | smoother |
See also: | regbwsel regxbwsel regest |
Quantlet: | regbwcrit | |
Description: | determines the optimal from a range of bandwidths by one using the resubstitution estimator with one of the following penalty functions: Shibata's penalty function (shi), Generalized Cross Validation (gcv), Akaike's Information Criterion (aic), Finite Prediction Error (fpe), Rice's T function (rice). The computation uses WARPing. |
Usage: | {hopt, ch} = regbwcrit(crit, x {,h {,K} {,d} }) | |
Input: | ||
crit | string, criterion for bandwidth selection: "shi", "gcv", "aic", "fpe", "rice". | |
x | n x 2 vector, the data. | |
h | m x 1 vector, vector of bandwidths. | |
K | string, kernel function on [-1,1] or Gaussian kernel "gau". If not given, "qua" is used. | |
d | scalar, discretization binwidth. d must be smaller than h. If not given, the minimum of min(h)/3 and (max(x)-min(x))/500 is used. | |
Output: | ||
hopt | scalar, optimal bandwidth. | |
ch | m x 2 vector, the criterion function for h values. |
library("smoother") x=read("nicfoo") h=grid(0.05,0.1,10) {hopt,ch}=regbwcrit("gcv",x,h) hopt library("plot") ch=setmask(ch,"line","blue") plot(ch) setgopt(plotdisplay,1,1,"title",string("hopt=%1.6g",hopt))
hopt is the LSCV optimal bandwidth for these data. The resulting curve for the LSCV criterion is plotted.