MVA.cv: Cross validation

View source: R/MVA.cv.R

MVA.cvR Documentation

Cross validation

Description

Performs cross validation with different PLS and/or discriminant analyses.

Usage

MVA.cv(X, Y, repet = 10, k = 7, ncomp = 8, scale = TRUE, model = c("PLSR",
  "CPPLS", "PLS-DA", "PPLS-DA", "LDA", "QDA", "PLS-DA/LDA", "PLS-DA/QDA",
  "PPLS-DA/LDA", "PPLS-DA/QDA"), lower = 0.5, upper = 0.5, Y.add = NULL,
  weights = rep(1, nrow(X)), set.prior = FALSE, crit.DA = c("plug-in",
  "predictive", "debiased"), ...)

Arguments

X

a data frame of independent variables.

Y

the dependent variable(s): numeric vector, data frame of quantitative variables or factor.

repet

an integer giving the number of times the whole procedure has to be repeated.

k

an integer giving the number of folds (can be re-set internally if needed).

ncomp

an integer giving the number of components to be used for all models except LDA and QDA (can be re-set depending on the size of the train sets).

scale

logical indicating if data should be scaled (see Details).

model

the model to be fitted (see Details).

lower

a vector of lower limits for power optimisation in CPPLS or PPLS-DA (see cppls.fit).

upper

a vector of upper limits for power optimisation in CPPLS or PPLS-DA (see cppls.fit).

Y.add

a vector or matrix of additional responses containing relevant information about the observations, in CPPLS or PPLS-DA (see cppls.fit).

weights

a vector of individual weights for the observations, in CPPLS or PPLS-DA (see cppls.fit).

set.prior

only used when a LDA or QDA is performed (coupled or not with a PLS model). If TRUE, the prior probabilities of class membership are defined according to the mean weight of individuals belonging to each class. If FALSE, prior probabilities are obtained from the data sets on which LDA/QDA models are built.

crit.DA

criterion used to predict class membership when a LDA or QDA is used. See predict.lda.

...

other arguments to pass to plsr (PLSR, PLS-DA) or cppls (CPPLS, PPLS-DA).

Details

When a discriminant analysis is used ("PLS-DA", "PPLS-DA", "LDA", "QDA", "PLS-DA/LDA", "PLS-DA/QDA", "PPLS-DA/LDA" or "PPLS-DA/QDA"), the training sets are generated in respect to the relative proportions of the levels of Y in the original data set (see splitf).

"PLS-DA" is considered as PLS2 on a dummy-coded response. For a PLS-DA based on the CPPLS algorithm, use "PPLS-DA" with lower and upper limits of the power parameters set to 0.5.

If scale = TRUE, the scaling is done as this: for each step of the validation loop (i.e. k steps), the training set is pre-processed by centering and unit-variance scaling. Means and standard deviations of variables in the training set are then used to scale the test set.

Value

model

model used.

type

type of model used.

repet

number of times the whole procedure was repeated.

k

number of folds.

ncomp

number of components used.

crit.DA

criterion used to classify individuals of the test sets.

groups

levels of Y if it is a factor.

models.list

list of of models generated (repet*k models), for PLSR, CPPLS, PLS-DA, PPLS-DA, LDA and QDA.

models1.list

list of of (P)PLS-DA models generated (repet*k models), for PLS-DA/LDA, PLS-DA/QDA, PPLS-DA/LDA and PPLS-DA/QDA.

models2.list

list of of LDA/QDA models generated (repet*k models), for PLS-DA/LDA, PLS-DA/QDA, PPLS-DA/LDA and PPLS-DA/QDA.

RMSEP

RMSEP vales (repet values).

Q2

Q2 values (repet values).

NMC

Classification error rates (repet values).

confusion

Confusion matrices (repet values).

pred.prob

Probability of each individual of being of each level of Y.

Author(s)

Maxime HERVE <maxime.herve@univ-rennes1.fr>

See Also

predict.MVA.cmv, mvr, lda, qda

Examples

require(pls)
require(MASS)

# PLSR
data(yarn)
## Not run: MVA.cv(yarn$NIR,yarn$density,model="PLSR")

# PPLS-DA coupled to LDA
data(mayonnaise)
## Not run: MVA.cv(mayonnaise$NIR,factor(mayonnaise$oil.type),model="PPLS-DA/LDA")

RVAideMemoire documentation built on Nov. 6, 2023, 5:07 p.m.