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

pcaDiag

Outlier Diagnostic Plots for PCA of a Spectra Object


Description

A function to carry diagnostics on the PCA results for a Spectra object. Basically a wrapper to Filzmoser's pcaDiagplot which colors everything according to the scheme stored in the Spectra object. Works with PCA results of either class prcomp or class princomp. Works with either classical or robust PCA results.

Usage

pcaDiag(
  spectra,
  pca,
  pcs = 3,
  quantile = 0.975,
  plot = c("OD", "SD"),
  use.sym = FALSE,
  ...
)

Arguments

spectra

An object of S3 class Spectra.

pca

An object of class prcomp modified to include a character string ($method) describing the pre-processing carried out and the type of PCA performed.

pcs

As per pcaDiagplot. The number of principal components to include.

quantile

As per pcaDiagplot. The significance criteria to use as a cutoff.

plot

A character string, indicating whether to plot the score distances or orthogonal distances, or both. Options are c("OD", "SD").

use.sym

logical; if true, the color scheme is change to black and symbols are used for plotting.

...

Additional parameters to be passed to the plotting functions.

Details

If both plots are desired, the output should be directed to a file rather than the screen. Otherwise, the 2nd plot overwrites the 1st in the active graphics window. Alternatively, just call the function twice, once specifying OD and once specifying SD.

Value

A list is returned as described in pcaDiagplot, so the result must be assigned or it will appear at the console. Side effect is a plot.

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

Additional documentation at https://bryanhanson.github.io/ChemoSpec/

pcaDiagplot in package chemometrics for the underlying function.

Examples

data(SrE.IR)
res <- c_pcaSpectra(SrE.IR, choice = "noscale")
temp <- pcaDiag(SrE.IR, res, pcs = 2, plot = "OD")
temp <- pcaDiag(SrE.IR, res, pcs = 2, plot = "SD")

ChemoSpec

Exploratory Chemometrics for Spectroscopy

v5.3.11
GPL-3
Authors
Bryan A. Hanson [aut, cre] (<https://orcid.org/0000-0003-3536-8246>), Mike Bostock [cph, ctb] (author of the d3.js library used by plotSpectraJS, http://d3js.org), Matt Keinsley [ctb] (author of initial AOV-PCA code)
Initial release
2021-03-24

We don't support your browser anymore

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