cv_model: K-fold cross-validation for models

View source: R/report_model.R

cv_modelR Documentation

K-fold cross-validation for models

Description

Returns cross-validated absolute fit values

Usage

cv_model(
  formula,
  data,
  k = 5,
  fit_function = "lm",
  metric = if (length(unique(data[, as.character(formula)[2]])) == 2) "AUC" else "RMSE",
  predict.control = list(NULL),
  ...
)

Arguments

formula

An object of class "formula" describing the model to be validated

data

A data frame containing the variables specified in formula argument

k

Number of folds

fit_function

Name of the model fitting function

metric

Performance metric to estimate: RMSE, MSE, MAE or AUC

predict.control

Named list of arguments to pass to the predict function of the model

...

Further arguments passed to the model fitting function

Value

Cross-validated values for the selected performance metric

Examples

cv_model(Petal.Length ~ Sepal.Width + Species, data=iris)

David-Hervas/repmod documentation built on Feb. 3, 2025, 11:38 a.m.