Learn R Programming

Momocs (version 1.4.1)

PCA: Principal component analysis on Coe objects

Description

Performs a PCA on Coe objects, using prcomp.

Usage

PCA(x, scale., center, fac)

# S3 method for OutCoe PCA(x, scale. = FALSE, center = TRUE, fac)

# S3 method for OpnCoe PCA(x, scale. = FALSE, center = TRUE, fac)

# S3 method for LdkCoe PCA(x, scale. = FALSE, center = TRUE, fac)

# S3 method for TraCoe PCA(x, scale. = TRUE, center = TRUE, fac)

# S3 method for default PCA(x, scale. = TRUE, center = TRUE, fac = dplyr::tibble())

as_PCA(x, fac)

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.

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.

See Also

Other multivariate: CLUST(), KMEANS(), KMEDOIDS(), LDA(), MANOVA_PW(), MANOVA(), MDS(), MSHAPES(), NMDS(), classification_metrics()

Examples

Run this code
bot.f <- efourier(bot, 12)
bot.p <- PCA(bot.f)
bot.p
plot(bot.p, morpho=FALSE)
plot(bot.p, 'type')

op <- npoly(olea, 5)
op.p <- PCA(op)
op.p
plot(op.p, 1, morpho=TRUE)

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)

Run the code above in your browser using DataLab