mvr objects.crossval(object, segments = 10,
segment.type = c("random", "consecutive", "interleaved"),
length.seg, jackknife = FALSE, trace = 15, ...)object is returned, with an additional component
validation, which is a list with components"CV" for cross-validation.jackknife is TRUE) an array
with the jackknifed regression coefficients. The dimensions
correspond to the predictors, responses, number of components, and
segments, respectively.ncomp components. Each row corresponds to one response variable.MSEP uses this.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(...,
validation = "CV"), but slower. Note that to use crossval, 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. See
cvsegments for details.
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.
If jackknife is TRUE, jackknifed regression coefficients
are returned, which can be used for for variance estimation
(var.jack) or hypothesis testing (jack.test).
When tracing is turned on, the segment number is printed for each segment.
mvr
mvrCv
cvsegments
MSEP
var.jack
jack.testdata(yarn)
yarn.pcr <- pcr(density ~ msc(NIR), 6, data = yarn)
yarn.cv <- crossval(yarn.pcr, segments = 10)
plot(MSEP(yarn.cv))Run the code above in your browser using DataLab