Last data update: 2014.03.03

R: Cross validation
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, 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).

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.

Value

model

model used.

type

type of model used.

repet

number of times the whole 2CV procedure was repeated.

k

number of folds.

k

number of components used.

crit.DA

criterion used to classify individuals of the test sets.

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

NMC values (repet values).

Author(s)

Maxime Herv<c3><a9> <mx.herve@gmail.com>

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")

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(RVAideMemoire)
*** Package RVAideMemoire v 0.9-56 ***
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/RVAideMemoire/MVA.cv.Rd_%03d_medium.png", width=480, height=480)
> ### Name: MVA.cv
> ### Title: Cross validation
> ### Aliases: MVA.cv
> 
> ### ** Examples
> 
> require(pls)
Loading required package: pls

Attaching package: 'pls'

The following object is masked from 'package:stats':

    loadings

> require(MASS)
Loading required package: 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")
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>