CV_mod: General function for cross-validation

Description Usage Arguments Value

View source: R/binary_search_mcr.r

Description

Calculate the cross-validated (CV) loss of a model fitting algorithm fit_fun.

Usage

1
2
CV_mod(y, X, n_folds = min(15, length(y)), fit_fun, report_fun,
  fit_in_sample = FALSE, verbose = FALSE)

Arguments

y

outcome vector

X

covariate matrix

n_folds

number of folds for CV

fit_fun

takes y, X as named arguments and returns a prediction model that can be entered into report_fun.

report_fun

has arguments mod, in the form of the returned value of fit_fun, as well as y and X, in the same format as the inputs y and X to the overall function CV_mod. The returned value of report_fun should be a numeric vector.

fit_in_sample

whether the within-fold performance metrics should also be reported, in addition to the out-of-fold metrics.

verbose

show progress bar

Value

The mean of report_fun's out-of-fold output, averaged across folds. If fit_in_sample=TRUE, the within-fold output is also shown.


aaronjfisher/mcr documentation built on Jan. 2, 2020, 4:38 p.m.