c_pcaSpectra: Classical PCA of Spectra Objects

View source: R/c_pcaSpectra.R

c_pcaSpectraR Documentation

Classical PCA of Spectra Objects

Description

A wrapper which carries out classical PCA analysis on a Spectra object. The user can select various options for scaling. There is no normalization by rows - do this manually using normSpectra. There is an option to control centering, but this is mainly for compatibility with the aov_pcaSpectra series of functions. Centering the data should always be done in PCA and it is the default here.

Usage

c_pcaSpectra(spectra, choice = "noscale", cent = TRUE)

Arguments

spectra

An object of S3 class Spectra().

choice

A character string indicating the choice of scaling. One of c("noscale", "autoscale", "Pareto"). "autoscale" is called "standard normal variate" or "correlation matrix PCA" in some literature.

cent

Logical: whether or not to center the data. Always center the data unless you know it to be already centered.

Details

The scale choice autoscale scales the columns by their standard deviation. Pareto scales by the square root of the standard deviation.

Value

An object of class prcomp, modified to include a list element called $method, a character string describing the pre-processing carried out and the type of PCA performed (used to annotate plots).

Author(s)

Bryan A. Hanson (DePauw University).

References

K. Varmuza and P. Filzmoser Introduction to Multivariate Statistical Analysis in Chemometrics, CRC Press, 2009.

See Also

prcomp for the underlying function, s_pcaSpectra for sparse PCA calculations, r_pcaSpectra for robust PCA calculations, irlba_pcaSpectra for PCA via the IRLBA algorithm. Additional documentation at https://bryanhanson.github.io/ChemoSpec/

For displaying the results, ChemoSpecUtils::plotScree(), ChemoSpecUtils::plotScores(), plotLoadings(), plot2Loadings(), sPlotSpectra().

Examples

## Not run: 
# This example assumes the graphics output is set to ggplot2 (see ?GraphicsOptions).
library("ggplot2")
data(metMUD1)
pca <- c_pcaSpectra(metMUD1)

p1 <- plotScree(pca)
p1

p2 <- plotScores(metMUD1, pca, pcs = c(1, 2), ellipse = "cls", tol = 0.05)
p2 <- p2 + ggtitle("Scores: metMUD1 NMR Data")
p2

p3 <- plotLoadings(metMUD1, pca, loads = 1:2, ref = 1)
p3 <- p3 + ggtitle("Loadings: metMUD1 NMR Data")
p3

## End(Not run)


ChemoSpec documentation built on June 7, 2023, 6:13 p.m.