Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

loocv.bca

Leave-one-out cross-validation for a bca


Description

Leave-one-out cross-validation to test the existence of spurious groups in bca in the case p (number of variables) > n (number of samples).

Usage

## S3 method for class 'between'
loocv(x, progress = FALSE, ...)

Arguments

x

the dudi of the bca on which cross-validation should be done

progress

logical to display a progress bar during computations (see the progress package)

...

further arguments passed to or from other methods

Details

This function returns a list containing the cross-validated coordinates of the rows (the rows of the original analysis, not the rows of the bca). The analysis on which the bca was computed is redone after removing each row of the data table, one at a time. A bca is done on this new analysis and the coordinates of the missing row are computed by projection as supplementary element in the corresponding bca. This is mostly useful in the case p >> n (many variables and few samples), where bca graphs can show spurious groups (see Refs.)

Value

A list with the cross-validated row coordinates XValCoord, the Predicted Residual Error Sum (PRESS, for each row and PRESSTot, its sum for each bca axis), the Root Mean Square Error (RMSE) and the IQR-standardized RMSE (RMSEIQR) for each bca axis.

Author(s)

Jean Thioulouse

References

Cardini A, O'Higgins P, Rohlf J. Seeing Distinct Groups Where There are None: Spurious Patterns from Between-Group PCA. Evolutionary Biology (2019) 46:303-316

Cardini A, Polly D. Cross-validated Between Group PCA Scatterplots: A Solution to Spurious Group Separation? Evolutionary Biology (2020) https://doi.org/10.1007/s11692-020-09494-x

Bookstein F. Pathologies of Between-Groups Principal Components Analysis in Geometric Morphometrics. Evolutionary Biology (2019) 46:271-302

See Also

Examples

# Data = meaudret
data(meaudret)
pca1 <- dudi.pca(meaudret$env, scannf = FALSE, nf = 3)
bca1 <- bca(pca1, meaudret$design$site, scannf = FALSE, nf = 3)
pst1 <- paste0("Meaudret BGA randtest: p=",
randtest(bca1)$pvalue, " ratio=", round(bca1$ratio, 2))

if(adegraphicsLoaded()){
    sc1 <- s.class(bca1$ls, meaudret$design$site, col = TRUE,
    psub.text = pst1, ellipseSize=0, chullSize=1, plot = FALSE)
    xbca1 <- loocv(bca1, progress = TRUE)
    sc2 <- s.class(xbca1$XValCoord, meaudret$design$site,
    col = TRUE, psub.text = "Meaudret cross-validation",
    ellipseSize=0, chullSize=1, plot = FALSE)
    ADEgS(list(sc1, sc2))
}
## Not run: 
# Data = rnorm()
set.seed(9)
fac1 <- as.factor(rep(1:3, each = 10))
tab <- as.data.frame(matrix(rnorm(10800), nrow = 30))
pca2 <- dudi.pca(tab, scannf = FALSE)
bca2 <- bca(pca2, fac1, scannf = FALSE)
pst2 <- paste0("rnorm spurious groups: p=",
randtest(bca2)$pvalue, " ratio=", round(bca2$ratio, 2))
sc3 <- s.class(bca2$ls, fac1, col = TRUE,
psub.text = pst2, ellipseSize=0, chullSize=1,
xlim = c(-8, 8), ylim = c(-8, 8), plot = FALSE)
xbca2 <- loocv(bca2, progress = TRUE)
sc4 <- s.class(xbca2$XValCoord, fac1, col = TRUE,
psub.text = "rnorm cross-validation", ellipseSize=0,
chullSize=1, xlim = c(-8, 8), ylim = c(-8, 8), plot = FALSE)
ADEgS(list(sc3, sc4))
## End(Not run)

ade4

Analysis of Ecological Data: Exploratory and Euclidean Methods in Environmental Sciences

v1.7-16
GPL (>= 2)
Authors
Stéphane Dray <stephane.dray@univ-lyon1.fr>, Anne-Béatrice Dufour <anne-beatrice.dufour@univ-lyon1.fr>, and Jean Thioulouse <jean.thioulouse@univ-lyon1.fr>, with contributions from Thibaut Jombart, Sandrine Pavoine, Jean R. Lobry, Sébastien Ollier, Daniel Borcard, Pierre Legendre, Stéphanie Bougeard and Aurélie Siberchicot. Based on earlier work by Daniel Chessel.
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.