A wrapper which carries out robust PCA analysis on a Spectra
object. The data are row- and column-centered, and the user can select
various options for scaling.
r_pcaSpectra(spectra, choice = "noscale")
An object of S3 class Spectra()
.
A character vector describing the type of scaling to be
carried out. One of c("noscale", "mad")
.
An object of classes converted_from_princomp
and prcomp
.
It includes a list element called $method
, a
character string describing the pre-processing carried out and the type of
PCA performed (used to annotate plots).
K. Varmuza and P. Filzmoser Introduction to Multivariate Statistical Analysis in Chemometrics, CRC Press, 2009.
PCAgrid
for the underlying function,
c_pcaSpectra
for classical PCA calculations,
s_pcaSpectra
for sparse 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()
.
if (FALSE) {
# This example assumes the graphics output is set to ggplot2 (see ?GraphicsOptions).
library("ggplot2")
data(metMUD1)
pca <- r_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
}