Use k-fold cross-validation to evaluate WRTDS model fit based on supplied half-window widths.
wrtdscv(dat_in, ...)
# S3 method for default
wrtdscv(dat_in, wins, k = 10, seed_val = 123, trace = TRUE, ...)
input tidal or tidalmean object
arguments passed to wrtds
or getwts
, e.g., tau = 0.2
if a tidal
object is used for dat_in
list of input half-window widths of the order months, years, and salinity/flow, passed to getwts
number of folds to evaluate
seed to keep the same dataset divisions between window width comparisons
logical indicating if progress is printed in the console
Overall error is the average of all errors for each fold.
Default number of folds is ten. Each fold can be evaluated with multiple cores if a parallel back end is created prior to running the function (see the examples). This will greatly increase processing speed unless k is set to a small number.
if (FALSE) {
library(doParallel)
ncores <- detectCores() - 1
registerDoParallel(cores = ncores)
# half-window widths to evaluate
# months, years, and salinity/flow
wins <- list(0.5, 10, 0.5)
# get ocv score for k = 10
wrtdscv(tidobjmean, wins = wins)
# get ocv score k = 2, tau = 0.2
wrtdscv(tidobj, wins = wins, tau = 0.2)
}