wrtdscv: Use k-fold cross-validation to evaluate WRTDS model fit

View source: R/wrtdscv.R

wrtdscvR Documentation

Use k-fold cross-validation to evaluate WRTDS model fit

Description

Use k-fold cross-validation to evaluate WRTDS model fit based on supplied half-window widths.

Usage

wrtdscv(dat_in, ...)

## Default S3 method:
wrtdscv(dat_in, wins, k = 10, seed_val = 123, trace = TRUE, ...)

Arguments

dat_in

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

wins

list of input half-window widths of the order months, years, and salinity/flow, passed to getwts

k

number of folds to evaluate

seed_val

seed to keep the same dataset divisions between window width comparisons

trace

logical indicating if progress is printed in the console

Details

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.

Value

Overall error is the average of all errors for each fold.

See Also

getwts, wtsplot, winsrch_grid, winsrch_optim

Examples

## Not run: 

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)

## End(Not run)

WRTDStidal documentation built on Oct. 20, 2023, 5:08 p.m.