Learn R Programming

cvTools (version 0.1.1)

cvReshape: Reshape cross-validation results

Description

Reshape cross-validation results into an object of class "cvSelect" with only one column of results.

Usage

cvReshape(x)

Arguments

x
an object inheriting from class "cv" or "cvSelect" that contains cross-validation results.

Value

  • An object of class "cvSelect" with the following components:
  • nan integer giving the number of observations.
  • Kan integer giving the number of folds used in cross-validation.
  • Ran integer giving the number of replications used in cross-validation.
  • bestan integer giving the index of the model with the best prediction performance.
  • cva data frame containing the estimated prediction errors for the models. For repeated cross-validation, those are average values over all replications.
  • repsa data frame containing the estimated prediction errors for the models from all replications. This is only returned if repeated cross-validation was performed for at least one of the models.

See Also

cvFit, cvSelect, cvTuning

Examples

Run this code
library("robustbase")
data("coleman")

# perform cross-validation for an LTS regression model
fitLts <- ltsReg(Y ~ ., data = coleman)
cvFitLts <- cvLts(fitLts, cost = rtmspe, K = 5, R = 10, 
    fit = "both", trim = 0.1, seed = 1234)
# compare original and reshaped object
cvFitLts
cvReshape(cvFitLts)

Run the code above in your browser using DataLab