Learn R Programming

chemometrics (version 1.4.4)

pcaCV: Determine the number of PCA components with repeated cross validation

Description

By splitting data into training and test data repeatedly the number of principal components can be determined by inspecting the distribution of the explained variances.

Usage

pcaCV(X, amax, center = TRUE, scale = TRUE, repl = 50, segments = 4, 
segment.type = c("random", "consecutive", "interleaved"), length.seg, trace = FALSE, 
plot.opt = TRUE, ...)

Value

ExplVar

matrix with explained variances, repl rows, and amax columns

MSEP

matrix with MSEP values, repl rows, and amax columns

Arguments

X

numeric data frame or matrix

amax

maximum number of components for evaluation

center

should the data be centered? TRUE or FALSE

scale

should the data be scaled? TRUE or FALSE

repl

number of replications of the CV procedure

segments

number of segments for CV

segment.type

"random", "consecutive", "interleaved" splitting into training and test data

length.seg

number of parts for training and test data, overwrites segments

trace

if TRUE intermediate results are reported

plot.opt

if TRUE the results are shown by boxplots

...

additional graphics parameters, see par

Author

Peter Filzmoser <P.Filzmoser@tuwien.ac.at>

Details

For cross validation the data are split into a number of segments, PCA is computed (using 1 to amax components) for all but one segment, and the scores of the segment left out are calculated. This is done in turn, by omitting each segment one time. Thus, a complete score matrix results for each desired number of components, and the error martrices of fit can be computed. A measure of fit is the explained variance, which is computed for each number of components. Then the whole procedure is repeated (repl times), which results in repl numbers of explained variance for 1 to amax components, i.e. a matrix. The matrix is presented by boxplots, where each boxplot summarized the explained variance for a certain number of principal components.

References

K. Varmuza and P. Filzmoser: Introduction to Multivariate Statistical Analysis in Chemometrics. CRC Press, Boca Raton, FL, 2009.

See Also

Examples

Run this code
data(glass)
x.sc <- scale(glass)
resv <- clvalidity(x.sc,clnumb=c(2:5))

Run the code above in your browser using DataLab