oscar.cv: Cross-validation for oscar-fitted model objects over k-range

View source: R/helpers.R

oscar.cvR Documentation

Cross-validation for oscar-fitted model objects over k-range

Description

Create a cross-validation matrix with the chosen goodness metric with n-folds. Based on the goodness metric, one ought to pick optimal cardinality (parameter 'k').

Usage

oscar.cv(
  fit,
  fold = 10,
  seed = NULL,
  strata = rep(1, times = nrow(fit@x)),
  verb = 0,
  ...
)

Arguments

fit

oscar-model object

fold

Number of cross-validation folds, Default: 10

seed

Random seed for reproducibility with NULL indicating that it is not set, Default: NULL

strata

Should stratified cross-validation be used; separate values indicate balanced strata. Default: Unit vector, which will treat all observations equally.

verb

Level of verbosity with higher integer giving more information, Default: 0

...

Additional parameters passed to oscar-function

Details

A k-fold cross-validation is run by mimicking the parameters contained in the original oscar S4-object. This requires the original data at slots @x and @y.

Value

A matrix with goodness of fit over folds and k-values

Examples

if(interactive()){
  data(ex)
  fit <- oscar(x=ex_X, y=ex_Y, k=ex_K, w=ex_c, family='cox')
  fit_cv <- oscar.cv(fit, fold=10, seed=123)
  fit_cv
}

oscar documentation built on Oct. 2, 2023, 5:08 p.m.