pcares | R Documentation |
pcares
is used to store and visualise results for PCA decomposition.
pcares(...)
... |
all arguments supported by |
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.
It is assumed that data is a matrix or data frame with I rows and J columns.
Returns an object (list) of class pcares
and ldecomp
with following fields:
scores |
matrix with score values (I x A). |
residuals |
matrix with data residuals (I x J). |
T2 |
matrix with score distances (I x A). |
Q |
matrix with orthogonal distances (I x A). |
ncomp.selected |
selected number of components. |
expvar |
explained variance for each component. |
cumexpvar |
cumulative explained variance. |
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 distance plot. |
Check also pca
and ldecomp
.
### 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, 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, 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)
plotResiduals(res, show.labels = TRUE, cgroup = people[, "Sex"])
plotResiduals(res, ncomp = 2, show.labels = TRUE)
par(mfrow = c(1, 1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.