pcares is used to store and visualise results for PCA decomposition.
pcares(...)
Arguments
...: all arguments supported by ldecomp.
Returns
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.
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.
It is assumed that data is a matrix or data frame with I rows and J columns.
Examples
### Examples for PCA results classlibrary(mdatools)## 1. Make a model for every odd row of People data## and apply it to the objects from every even rowdata(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 resultsdata(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 resultspar(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 resultspar(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))