Learn R Programming

lava (version 1.6.4)

cv: Cross-validation

Description

Cross-validation

Usage

cv(modelList, data, K = 5, rep = 1, perf, seed = NULL,
  mc.cores = 1, shared = NULL, ...)

Arguments

modelList

List of fitting functions or models

data

data.frame

K

Number of folds (default 5, 0 splits in 1:n/2, n/2:n with last part used for testing)

rep

Number of repetitions (default 1)

perf

Performance measure (default RMSE)

seed

Optional random seed

mc.cores

Number of cores used for parallel computations

shared

function applied to each fold with results send to each model

...

Additional arguments parsed to models in modelList and perf

Details

Generic cross-validation function

Examples

Run this code
# NOT RUN {
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