pca: Principal Components Analysis

pcaR Documentation

Principal Components Analysis

Description

Performs a principal components analysis on the given data matrix and returns the results as an object of class "prcomp".

Usage

pca(x, ...)

Arguments

x

a matrix of data.

...

arguments passed to prcomp function.

Value

The function returns a list with class prcomp containing the following components:

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).

rotation

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

x

if retx is TRUE the value of the rotated data (the centred (and scaled if requested) data multiplied by the rotation matrix) is returned. Hence, cov(x) is the diagonal matrix diag(sdev^2). For the formula method, napredict() is applied to handle the treatment of values omitted by the na.action.

center, scale

the centering and scaling used, or FALSE.

txt

the component of variance of each Principal Component.

Author(s)

Stefano Cacciatore

References

Pearson, K
On Lines and Planes of Closest Fit to Systems of Points in Space.
Philosophical Magazine 1901;2 (11): 559-572. doi:10.1080/14786440109462720. Link

See Also

prcomp

Examples

data(MetRef)
u=MetRef$data;
u=u[,-which(colSums(u)==0)]
u=normalization(u)$newXtrain
u=scaling(u)$newXtrain
class=as.numeric(as.factor(MetRef$gender))
cc=pca(u)
plot(cc$x,pch=21,bg=class)

KODAMA documentation built on Jan. 12, 2023, 5:08 p.m.