To compute the optimal bandwidth using the bootstrap method with resampling.
bw.dboot2(y,sig,h0='dboot1',error='normal',B=1000,grid=100,ub=2)
The observed data. It is a vector of length at least 3.
The standard deviation(s)
An initial bandwidth parameter. The default vaule is the estimate from bw.dboot1.
Error distribution types: 'normal', 'laplacian' for normal and Laplacian errors, respectively.
Bootstrap number, default value 1000.
the grid number to search the optimal bandwidth when a bandwidth selector was specified in bw. Default value "grid=100".
the upper boundary to search the optimal bandwidth, default value is "ub=2".
the selected bandwidth.
Three cases are supported: (1) homo normal; (2) homo laplacian.
The integration was approximated by computing the average over a fine grid of points (1000 points).
Wang, X.F. and Wang, B. (2011). Deconvolution estimation in measurement error models: The R package decon. Journal of Statistical Software, 39(10), 1-24.
# NOT RUN {
n <- 1000
x <- c(rnorm(n/2,-2,1),rnorm(n/2,2,1))
## the case of homoscedastic normal error
sig <- .8
u <- rnorm(n, sd=sig)
w <- x+u
bw.dboot2(w,sig=sig)
## the case of homoscedastic laplacian error
sig <- .8
## generate laplacian error
u <- ifelse(runif(n) > 0.5, 1, -1) * rexp(n,rate=1/sig)
w <- x+u
bw.dboot2(w,sig=sig,error='laplacian')
# }
Run the code above in your browser using DataLab