pcaCV | R Documentation |

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.

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

`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 |

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.

`ExplVar ` |
matrix with explained variances, repl rows, and amax columns |

`MSEP ` |
matrix with MSEP values, repl rows, and amax columns |

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

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

`princomp`

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

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.