mvr objects.crossval(object, segments = 10,
segment.type = c("random", "consecutive", "interleaved"),
length.seg, trace = 15, ...)mvr object; the regression to cross-validate.loo = TRUE.segments is a list.segments unless
segments is a list.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.object is returned, with an additional component
validation, which is a list with components"CV" for cross-validation.ncomp components. Each row corresponds to one response variable.MSEP uses this.ncomp components. Each row corresponds to one response variable.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.
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.
mvr
mvrCv
cvsegments
MSEPdata(NIR)
NIR.pcr <- pcr(y ~ msc(X), 6, data = NIR)
NIR.cv <- crossval(NIR.pcr, segments = 10)
plot(MSEP(NIR.cv))Run the code above in your browser using DataLab