
Last chance! 50% off unlimited learning
Sale ends in
Cross-validation
cv(modelList, data, K = 5, rep = 1, perf, seed = NULL, shared = NULL, ...)
List of fitting functions or models
data.frame
Number of folds (default 5, 0 splits in 1:n/2, n/2:n with last part used for testing)
Number of repetitions (default 1)
Performance measure (default RMSE)
Optional random seed
function applied to each fold with results send to each model
Additional arguments parsed to models in modelList and perf
Klaus K. Holst
Generic cross-validation function
f0 <- function(data,...) lm(...,data)
f1 <- function(data,...) lm(Sepal.Length~Species,data)
f2 <- function(data,...) lm(Sepal.Length~Species+Petal.Length,data)
x <- cv(list(m0=f0,m1=f1,m2=f2),rep=10, data=iris, formula=Sepal.Length~.)
x2 <- cv(list(f0(iris),f1(iris),f2(iris)),rep=10, data=iris)
Run the code above in your browser using DataLab