Cross-validation of groc models

Description

A “stand alone” cross-validation function for groc objects.

Usage

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

Arguments

object

a groc object; the regression to cross-validate.

segments

the number of segments to use, or a list with segments (see below).

segment.type

the type of segments to use.

length.seg

Positive integer. The length of the segments to use.

trace

if TRUE, tracing is turned on. If numeric, it denotes a time limit (in seconds). If the estimated total time of the cross-validation exceeds this limit, tracing is turned on.

...

additional arguments, sent to the underlying fit function.

Details

This function performs cross-validation on a model fit by groc. It can handle models such as groc(Y ~ X, ...).

Note that to use grocCrossval, the data must be specified with a data argument when fitting object.

If segments is a list, the arguments segment.type and length.seg are ignored. The elements of the list should be integer vectors specifying the indices of the segments.

Otherwise, segments of type segment.type are generated. How many segments to generate is selected by specifying the number of segments in segments, or giving the segment length in length.seg. If both are specified, segments is ignored.

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

Value

The supplied object is returned, with an additional component validation, which is a list with components

method

equals "CV" for cross-validation.

pred

an array with the cross-validated predictions.

PRESS

a matrix of PRESS values for models with 1, ..., ncomp components. Each row corresponds to one response variable.

PREMAD

a matrix of PREMAD values for models with 1, ..., ncomp components. Each row corresponds to one response variable.

RMSEP

a matrix of sqrt(PRESS/nobj) values for models with 1, ..., ncomp components. Each row corresponds to one response variable.

segments

the list of segments used in the cross-validation.

ncomp

the number of components.

Author(s)

Martin Bilodeau (bilodeau@dms.umontreal.ca) and Pierre Lafaye de Micheaux (lafaye@dms.umontreal.ca)

References

Martin Bilodeau, Pierre Lafaye de Micheaux, Smail Mahdi (2015), The R Package groc for Generalized Regression on Orthogonal Components, Journal of Statistical Software, 65(1), 1-29,
http://www.jstatsoft.org/v65/i01/

Examples

1
2
3
4
5
6
data(yarn,package="pls")
yarn.groc <- groc(density ~ NIR, 6, data = yarn)
yarn.cv <- grocCrossval(yarn.groc, segments = 10)

yarn.cv$validation$PRESS
yarn.cv$validation$PREMAD