# regCVBwSelC: Cross Validation Bandwidth selector. In locpol: Kernel Local Polynomial Regression

## Description

Implements Cross validation bandwidth selector for the regression function.

## Usage

 ```1 2``` ```regCVBwSelC(x, y, deg, kernel=gaussK,weig=rep(1,length(y)), interval=.lokestOptInt) ```

## Arguments

 `x` x covariate values. `y` y response values. `deg` degree of the local polynomial. `kernel` Kernel used to perform the estimation, see `Kernels`. `weig` Vector of weights for observations. `interval` An interval where to look for the bandwidth.

## Details

Computes the weighted ASE for every bandwidth returning the minimum. The function is implemented by means of a C function that computes for a single bandwidth the ASE, and a call to `optimise` on a given interval.

A numeric value.

## Author(s)

Jorge Luis Ojeda Cabrera.

## References

Fan, J. and Gijbels, I. Local polynomial modelling and its applications\/. Chapman \& Hall, London (1996).

H\"ardle W.(1990) Smoothing techniques. Springer Series in Statistics, New York (1991).

Wand, M.~P. and Jones, M.~C. Kernel smoothing\/. Chapman and Hall Ltd., London (1995).

`thumbBw`, `pluginBw`.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30``` ``` size <- 200 sigma <- 0.25 deg <- 1 kernel <- EpaK xeval <- 0:100/100 regFun <- function(x) x^3 x <- runif(size) y <- regFun(x) + rnorm(x, sd = sigma) d <- data.frame(x, y) cvBwSel <- regCVBwSelC(d\$x,d\$y, deg, kernel, interval = c(0, 0.25)) thBwSel <- thumbBw(d\$x, d\$y, deg, kernel) piBwSel <- pluginBw(d\$x, d\$y, deg, kernel) est <- function(bw, dat, x) return(locPolSmootherC(dat\$x,dat\$y, x, bw, deg, kernel)\$beta0) ise <- function(val, est) return(sum((val - est)^2 * xeval[[2]])) plot(d\$x, d\$y) trueVal <- regFun(xeval) lines(xeval, trueVal, col = "red") xevalRes <- est(cvBwSel, d, xeval) cvIse <- ise(trueVal, xevalRes) lines(xeval, xevalRes, col = "blue") xevalRes <- est(thBwSel, d, xeval) thIse <- ise(trueVal, xevalRes) xevalRes <- est(piBwSel, d, xeval) piIse <- ise(trueVal, xevalRes) lines(xeval, xevalRes, col = "blue", lty = "dashed") res <- rbind( bw = c(cvBwSel, thBwSel, piBwSel), ise = c(cvIse, thIse, piIse) ) colnames(res) <- c("CV", "th", "PI") res ```

### Example output

```             CV          th          PI
bw  0.194154914 0.134354897 0.110312684
ise 0.003658339 0.004085551 0.004529838
```

locpol documentation built on May 25, 2018, 1:05 a.m.