dat_in: input data object to use with weighted regression
...: arguments passed to or from other methods
grid_in: optional input matrix of half-window widths created with createsrch, a default search grid is used if no input
Returns
A data frame of the search grid with associated errors for each cross-validation result. Errors for each grid row are averages of all errors for each fold used in cross-validation.
Details
Processing time can be reduced by setting up a parallel backend, as in the examples. Note that this is not effective for small k-values (e.g., < 4) because each fold is sent to a processor, whereas the window width combinations in grid_in are evaluated in sequence.
This function should only be used to view the error surface associated with finite combinations of window-width combinations. A faster function to identify the optimal window widths is provided by winsrch_optim.
Examples
## Not run:### setup parallel backendlibrary(doParallel)ncores <- detectCores()-2registerDoParallel(cores = ncores)# run search function using default search grid - takes a whileres <- winsrch_grid(tidobjmean)# view the error surface library(ggplot2)ggplot(res, aes(x = factor(mos), y = factor(yrs), fill = err))+ geom_tile()+ facet_wrap(~ flo)+ scale_x_discrete(expand = c(0,0))+ scale_y_discrete(expand = c(0,0))+ scale_fill_gradientn(colours = gradcols())# optimal combores[which.min(res$err),]### create a custom search grid, e.g. years onlygrid_in <- createsrch(mos =1, yrs = seq(1,10), flo =1)res <- winsrch_grid(tidobjmean, grid_in)## End(Not run)