cv_mb: Cross-validation

Description Usage Arguments Value Examples

View source: R/mass-balance-optim.R

Description

Cross-validation

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
cv_mb(
  instQ,
  pc.list,
  cv.folds,
  start.year,
  lambda = 1,
  log.trans = NULL,
  force.standardize = FALSE,
  return.type = c("fval", "metrics", "metric means", "Q")
)

Arguments

instQ

Instrumental data, in the same order as pc.list. The "season" column must be a factor.

pc.list

List of PC matrices

cv.folds

A list containing the cross validation folds

start.year

The first year of record

lambda

The penalty weight

log.trans

A vector containing indices of the targets to be log-transformed. If no transformation is needed, provide NULL.

force.standardize

If TRUE, all observations are standardized. See Details.

return.type

The type of results to be returned. Several types are possible to suit multiple use cases.

fval

Only the objective function value (penalized least squares) is returned; this is useful for the outer optimization for site selection.

metrics

all performance metrics are returned.

metric means

the Tukey's biweight robust mean of each metric is returned.

Q

The predicted flow in each cross-validation run is returned. This is the most basic output, so that you can use it to calculate other metrics that are not provided by the package.

Value

A data.table containing cross-validation results (metrics, fval, or metric means) for each target.

Examples

1
2
cvFolds <- make_Z(1922:2003, nRuns = 50, frac = 0.25, contiguous = TRUE)
cv <- cv_mb(p1Seasonal, pc3seasons, cvFolds, 1750, log.trans = 1:3, return.type = 'metrics')

mbr documentation built on Feb. 16, 2021, 5:07 p.m.