mvr objects.crossval(object, segments = 10,
segment.type = c("random", "consecutive", "interleaved"),
length.seg, trace = 15, ...)object is returned, with an additional component
validation, which is a list with componentsncomp 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(..., 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.
mvr
mvrCv
cvsegments
MSEPdata(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