Learn R Programming

mdatools (version 0.9.1)

pcares: Results of PCA decomposition

Description

pcares is used to store results for PCA decomposition of data.

Usage

pcares(...)

Arguments

...

other arguments supported by ldecomp.

Value

Returns an object (list) of class pcares and ldecomp with following fields:

scores

matrix with score values (nobj x ncomp).

residuals

matrix with data residuals (nobj x nvar).

T2

matrix with T2 distances (nobj x ncomp).

Q

matrix with Q residuals (nobj x ncomp).

tnorm

vector with singular values used for scores normalization.

ncomp.selected

selected number of components.

expvar

explained variance for each component.

cumexpvar

cumulative explained variance.

Details

In fact pcares is a wrapper for ldecomp - general class for storing results for linear decomposition X = TP' + E. So, most of the methods, arguments and returned values are inherited from ldecomp.

There is no need to create a pcares object manually, it is created automatically when build a PCA model (see pca) or apply the model to a new data (see predict.pca). The object can be used to show summary and plots for the results.

See Also

Methods for pcares objects:

print.pcares shows information about the object.
summary.pcares shows statistics for the PCA results.

Methods, inherited from ldecomp class:

plotScores.ldecomp makes scores plot.
plotVariance.ldecomp makes explained variance plot.
plotCumVariance.ldecomp makes cumulative explained variance plot.
plotResiduals.ldecomp makes Q vs. T2 residuals plot.

Check also pca and ldecomp.

Examples

Run this code
# NOT RUN {
### Examples for PCA results class

library(mdatools)

## 1. Make a model for every odd row of People data
## and apply it to the objects from every even row

data(people)
x = people[seq(1, 32, 2), ]
x.new = people[seq(1, 32, 2), ]

model = pca(people, scale = TRUE, cv = 1, info = 'Simple PCA model')
model = selectCompNum(model, 4)

res = predict(model, x.new)
summary(res)
plot(res)

## 1. Make PCA model for People data with autoscaling
## and full cross-validation and get calibration results


data(people)
model = pca(people, scale = TRUE, cv = 1, info = 'Simple PCA model')
model = selectCompNum(model, 4)

res = model$calres
summary(res)
plot(res)

## 2. Show scores plots for the results
par(mfrow = c(2, 2))
plotScores(res)
plotScores(res, cgroup = people[, 'Beer'], show.labels = TRUE)
plotScores(res, comp = c(1, 3), show.labels = TRUE)
plotScores(res, comp = 2, type = 'h', show.labels = TRUE)
par(mfrow = c(1, 1))

## 3. Show residuals and variance plots for the results
par(mfrow = c(2, 2))
plotVariance(res, type = 'h')
plotCumVariance(res, show.labels = TRUE, legend.position = 'bottomright')
plotResiduals(res, show.labels = TRUE, cgroup = people[, 'Sex'])
plotResiduals(res, ncomp = 2, show.labels = TRUE)
par(mfrow = c(1, 1))

# }

Run the code above in your browser using DataLab