pls (version 1.0-1)

crossval: Cross-validation of PLSR and PCR models

Description

A stand alone cross-validation function for mvr objects.

Usage

crossval(object, segments = 10,
         segment.type = c("random", "consecutive", "interleaved"),
         length.seg, trace = 15, ...)

Arguments

Value

  • The supplied object is returned, with an additional component validation, which is a list with components
  • methodeuqals "CV" for cross-validation.
  • predan array with the cross-validated predictions.
  • MSEP0a vector of MSEP values (one for each response variable) for a model with zero components, i.e., only the intercept.
  • MSEPa matrix of MSEP values for models with 1, ..., ncomp components. Each row corresponds to one response variable.
  • adja matrix of adjustment values for calculating bias corrected MSEP. MSEP uses this.
  • R2a matrix of R2 values for models with 1, ..., ncomp components. Each row corresponds to one response variable.
  • segmentsthe list of segments used in the cross-validation.

Details

This function performs cross-validation on a model fit by mvr. It can handle models such as plsr(y ~ msc(X), ...) or other models where the predictor variables need to be recalculated for each segment. When recalculation is not needed, the result of crossval(mvr(...)) is identical to mvr(..., CV = TRUE), but slower.

If length.seg is specified, segments of the requested length are used. Otherwise: If segments is a number, it specifies the number of segments to use, and segment.type is used to select the type of segments. If segments is a list, the elements of the list should be integer vectors specifying the indices of the segments. See cvsegments for details.

The R2 component returned is calculated as the squared correlation between the cross-validated predictions and the responses.

When tracing is turned on, the segment number is printed for each segment.

References

Mevik, B.-H., Cederkvist, H. R. (2004) Mean Squared Error of Prediction (MSEP) Estimates for Principal Component Regression (PCR) and Partial Least Squares Regression (PLSR). Journal of Chemometrics, 18(9), 422--429.

See Also

mvr mvrCv cvsegments MSEP

Examples

Run this code
data(NIR)
NIR.pcr <- pcr(y ~ msc(X), 6, data = NIR)
NIR.cv <- crossval(NIR.pcr, CV = TRUE, segments = 10)
plot(MSEP(NIR.cv))

Run the code above in your browser using DataLab