lspls (version 0.2-2)

lsplsCv: Cross-Validate LS-PLS Models

Description

Calculate cross-validated predictions for LS-PLS models.

Usage

lsplsCv(formula, ncomp, data, subset, na.action, segments = 10,
        segment.type = c("random", "consecutive", "interleaved"),
        length.seg, model = TRUE, …)

Arguments

formula

model formula. See Details.

ncomp

list or vector of positive integers, giving the number of components to use for each PLS matrix. See Details.

data

an optional data frame with the data to fit the model from.

subset

an optional vector specifying a subset of observations to be used in the fitting process.

na.action

a function which indicates what should happen when the data contain missing values.

segments

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

segment.type

the type of segments to use. Ignored if segments is a list.

length.seg

Positive integer. The length of the segments to use. If specified, it overrides segments unless segments is a list.

model

logical. If TRUE, the model frame is returned.

additional arguments, passed to the underlying cross-validation function (currently orthlsplsCv).

Value

An object of class "lsplsCv", with components

pred

the cross-validated predictions. An array with one dimension for the observations, one for the responses, and one for each of the PLS matrices.

segments

the list of segments used in the cross-validation.

na.action

if observations with missing values were removed, na.action contains a vector with their indices.

ncomp

the list of number of components used in the model.

call

the function call.

terms

the model terms.

model

if model = TRUE, the model frame.

Details

The function performs a cross-validation, using the model and segments specified in the call. It returns an object of class "lsplsCv", which has a plot method (see plot.lsplsCv). See lspls-package for typical usage and more about LS-PLS models.

See lspls for details about specifying the model with formula and ncomp. Note that lsplsCv cross-validates models with from 0 components to the numbers of components specified with ncomp.

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.

References

J<U+00F8>rgensen, K., Segtnan, V. H., Thyholt, K., N<U+00E6>s, T. (2004) A Comparison of Methods for Analysing Regression Models with Both Spectral and Designed Variables. Journal of Chemometrics, 18(10), 451--464.

J<U+00F8>rgensen, K., Mevik, B.-H., N<U+00E6>s, T. Combining Designed Experiments with Several Blocks of Spectroscopic Data. (Submitted)

Mevik, B.-H., J<U+00F8>rgensen, K., M<U+00E5>ge, I., N<U+00E6>s, T. LS-PLS: Combining Categorical Design Variables with Blocks of Spectroscopic Measurements. (Submitted)

See Also

lspls, plot.lsplsCv, cvsegments, orthlsplsCv, lspls-package

Examples

Run this code
# NOT RUN {
##FIXME
# }

Run the code above in your browser using DataLab