Learn R Programming

hyperSpec (version 0.98-20140523)

decomposition: Convert Principal Component Decomposition or the like into a hyperSpec Object

Description

Decomposition of the spectra matrix is a common procedure in chemometric data analysis. scores and loadings convert the result matrices into new hyperSpec objects.

Usage

decomposition(object, x, wavelength = seq_len(ncol(x)),
    label.wavelength, label.spc, scores = TRUE,
    retain.columns = FALSE, short = "decomposition",
    user = NULL, date = NULL, ...)

Arguments

object
A hyperSpec object.
x
matrix with the new content for object@data$spc.

Its size must correspond to rows (for scores) and to either columns or rows (for loadings) of object.

wavelength
for a scores-like x: the new object@wavelength.
label.wavelength
The new label for the wavelength axis (if x is scores-like)
label.spc
The new label for the spectra matrix
scores
is x a scores-like matrix?
retain.columns
for loading-like decompostition (i.e. x holds loadings, pure component spectra or the like), the data columns need special attention.

Columns with different values across the rows will be set to NA if retain.column

short,user,date
ignored: logbook is deprecated
...
ignored.

Value

  • A hyperSpec object, updated according to x

code

plotc

Details

Multivariate data are frequently decomposed by methods like principal component analysis, partial least squares, linear discriminant analysis, and the like. These methods yield latent spectra (or latent variables, loadings, components, ...

See Also

See %*% for matrix multiplication of hyperSpec objects.

See e.g. prcomp and princomp for principal component analysis, and package pls for Partial Least Squares Regression.

Examples

Run this code
pca <- prcomp (flu)

pca.loadings <- decomposition (flu, t (pca$rotation), scores = FALSE)
pca.center <- decomposition (flu, pca$center, scores = FALSE)
pca.scores <- decomposition (flu, pca$x)

plot (pca.center)
plot (pca.loadings, col = c ("red", "gray50"))
plotc (pca.scores, groups = .wavelength)

Run the code above in your browser using DataLab