## Compute the cross-validation bandwidth for a sample of 100 random N(0,1) data
x<-rnorm(100,0,1)
num_bws <- 50
seq_bws <- seq(((max(x)-min(x))/2)/50,(max(x)-min(x))/2,length=num_bws)
hCV <- CVbw(type_kernel="e", vec_data=x, n_pts=200, seq_bws=seq_bws)
hCV
## The CV function is plotted
h_CV<-CVbw(vec_data=x)
h_CV$bw
plot(h_CV$seq_bws, h_CV$CVfunction, type="l")
## Not run:
# ## Plotting the distribution function estimate controling the grid points
# ## and the kernel function
# ss <- quantile(x, c(0.05, 0.95))
# # number of points to be used in the representation of estimated distribution
# # function
# n_pts <- 100
# y <- seq(ss[1],ss[2],length.out=n_pts)
# F_CV<-kde(type_kernel="e", x, y, h_CV$bw)$Estimated_values
# ## plot of the theoretical and estimated distribution functions
# require(graphics)
# plot(y,F_CV, type="l", lty=2)
# lines(y, pnorm(y),type="l", lty=1)
# legend(-1,0.8,c("real","nonparametric"),lty=1:2)
# ## End(Not run)
Run the code above in your browser using DataLab