Learn R Programming

hyperSpec (version 0.98-20110927)

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

Description

Convert Principal Component Decomposition or the like into a hyperSpec Object Decomposition of the spectra matrix is a common procedure in chemometrix data analysis. decomposition converts 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.

May correspond to rows (like a scores matrix) or columns (like a loadings matrix) 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.columns

short,user,date
handed over to logentry
...
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 loadings (or latent variables, 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 (~ spc, data = flu$., center = FALSE)

scores <- decomposition (flu, pca$x, label.wavelength = "PC",
label.spc = "score / a.u.")

loadings <- decomposition (flu, t(pca$rotation), scores = FALSE,
label.spc = "loading I / a.u.")

plotspc (loadings, stacked = TRUE, col = matlab.palette(6))

plotc (scores, groups = .wavelength,col = matlab.palette(6), type = "b")
pca$sdev

## everything besides the first component is just noise
## Reconstructing the data using only the first PC results in a noise
## filtered data set.

flu.filtered <- scores[,,1]

## example 2
pca <- prcomp (~ spc, data = chondro$., tol = 0.1)

scores <- decomposition (chondro, pca$x, label.wavelength = "PC",
label.spc = "score / a.u.")

plotmap (scores[,,1])

Run the code above in your browser using DataLab