# PCA: Principal component analysis on Coe objects In Momocs: Morphometrics using R

## Description

Performs a PCA on Coe objects, using prcomp.

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18``` ```PCA(x, scale., center, fac) ## S3 method for class 'OutCoe' PCA(x, scale. = FALSE, center = TRUE, fac) ## S3 method for class 'OpnCoe' PCA(x, scale. = FALSE, center = TRUE, fac) ## S3 method for class 'LdkCoe' PCA(x, scale. = FALSE, center = TRUE, fac) ## S3 method for class 'TraCoe' PCA(x, scale. = TRUE, center = TRUE, fac) ## Default S3 method: PCA(x, scale. = TRUE, center = TRUE, fac = data.frame()) as.PCA(x, fac) ```

## Arguments

 `x` a Coe object or an appropriate object (eg prcomp) for `as.PCA` `scale.` logical whether to scale the input data `center` logical whether to center the input data `fac` any factor or data.frame to be passed to `as.PCA` and for use with plot.PCA

## Details

By default, methods on Coe object do not scale the input data but center them. There is also a generic method (eg for traditional morphometrics) that centers and scales data.

## Value

a 'PCA' object on which to apply plot.PCA, among others. This list has several components, most of them inherited from the `prcomp` object:

1. `sdev` the standard deviations of the principal components (i.e., the square roots of the eigenvalues of the covariance/correlation matrix, though the calculation is actually done with the singular values of the data matrix)

2. `eig` the cumulated proportion of variance along the PC axes

3. `rotation` the matrix of variable loadings (i.e., a matrix whose columns contain the eigenvectors). The function princomp returns this in the element loadings.

4. `center`, scale the centering and scaling used

5. `x` PCA scores (the value of the rotated data (the centred (and scaled if requested) data multiplied by the rotation matrix))

6. other components are inherited from the `Coe` object passed to `PCA`, eg `fac`, `mshape`, `method`, `baseline1` and `baseline2`, etc. They are documented in the corresponding `*Coe` file.

Other multivariate: `CLUST`, `KMEANS`, `LDA`, `MANOVA_PW`, `MANOVA`, `classification_metrics`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25``` ```data(bot) bot.f <- efourier(bot, 12) bot.p <- PCA(bot.f) bot.p plot(bot.p, morpho=FALSE) plot(bot.p, 'type') data(olea) op <- npoly(olea, 5) op.p <- PCA(op) op.p plot(op.p, 1, morpho=TRUE) data(wings) wp <- fgProcrustes(wings, tol=1e-4) wpp <- PCA(wp) wpp plot(wpp, 1) # "foreign prcomp" head(iris) iris.p <- prcomp(iris[, 1:4]) iris.p <- as.PCA(iris.p, iris[, 5]) class(iris.p) plot(iris.p, 1) ```