Learn R Programming

RVAideMemoire (version 0.9-54)

MVA.cv: Cross validation

Description

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

Usage

MVA.cv(X, Y, repet = 10, k = 7, ncomp = 5, 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 2CV procedure has to be repeated.
k
an integer giving the number of folds.
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).
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 pro
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).

Value

  • modelmodel used.
  • typetype of model used.
  • repetnumber of times the whole 2CV procedure was repeated.
  • knumber of folds.
  • knumber of components used.
  • crit.DAcriterion used to classify individuals of the test sets.
  • models.listlist of of models generated (repet*k models), for PLSR, CPPLS, PLS-DA, PPLS-DA, LDA and QDA.
  • models1.listlist 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.listlist of of LDA/QDA models generated (repet*k models), for PLS-DA/LDA, PLS-DA/QDA, PPLS-DA/LDA and PPLS-DA/QDA.
  • RMSEPRMSEP vales (repet values).
  • Q2Q2 values (repet values).
  • NMCNMC values (repet values).

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.

See Also

predict.MVA.cmv, mvr, lda, qda

Examples

Run this code
require(pls)
require(MASS)

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

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

Run the code above in your browser using DataLab