Learn R Programming

cocorresp (version 0.4-6)

crossval: Cross-validation for predictive Co-Correspondence Analysis models

Description

Performs a leave-one-out cross-validation of a predictive Co-Correspondence Analysis model.

Usage

crossval(y, x, n.axes = min(dim(x), dim(y)) - 1,
         centre = TRUE, verbose = TRUE)

# S3 method for crossval summary(object, axes = c(1:min(6, object$n.axes)), ...)

Value

Returns a large list with the following components:

dimx, dimy

the dimensions of the input matrices x and y respectively.

press0

the \(press_0\) statistic.

n.axes

the number of axes tested.

CVfit

the cross-validatory fit.

varianceExp

list with components Yblock and Xblock containing the variances in the response and the predictor respectively, explained by each fitted PLS axis.

totalVar

list with components Yblock and Xblock containing the total variance in the response and the predictor respectively.

nam.dat

list with components namY and namX containing the names of the response and the predictor(s) respectively.

call

the R call used.

Arguments

y

the response species matrix.

x

the predictor species matrix.

n.axes

the number of axes to calculate the leave-one-out cross-validation for. Default is to perform the CV for all extractable axes.

centre

centre y and x during analysis? Currently ignored as it may not be necessary.

verbose

if TRUE, the default, print information on the progress of the cross-validation procedure.

object

an object of class crossval as returned by crossval.

axes

the number of axes to summarise results for.

...

further arguments to print - currently ignored.

Author

Gavin L. Simpson, based on Matlab code by C.J.F. ter Braak and A.P. Schaffers.

Details

Performs a leave-one-out cross-validation of a predictive Co-Correspondence Analysis model. It can be slow depending on the number of columns in the matrices, and of course the number of sites.

See Also

The model fitting function coca

Examples

Run this code
od <- options(digits = 4)
## load the data sets
data(beetles)
data(plants)

## log transform the bettle data
beetles <- log(beetles + 1)

## predictive CoCA using SIMPLS and formula interface
bp.pred <- coca(beetles ~ ., data = plants)
## should retain only the useful PLS components for a
## parsimonious model

## Leave-one-out crossvalidation - this takes a while
if (FALSE) {
crossval(beetles, plants)
}
## so 2 axes are sufficient
options(od)

Run the code above in your browser using DataLab