calcPCA {psvd} | R Documentation |
Perform principal component analysis
Description
Given a data matrix, the function allows to perform principal component analysis using a power method to get the eigendecomposition.
Usage
calcPCA(X, r, eta, itmax, err, normed, mySeed)
Arguments
X |
Data matrix of size (m,n), m >= n. |
r |
Number of principal components, default: r=2. |
eta |
Power method tuning parameter, default: eta=10. |
itmax |
Maximum number of iteration in the power method, default: itmax=200. |
err |
Tolerance level in the power method, default: err=1e-8. |
normed |
TRUE (default) or FALSE for PCA using standardized data or not. |
mySeed |
An integer allowing to reproduce results from two different runs, default: mySeed=50. |
Details
X is usually a data matrix .
Value
This function returns a data frame containing 5 components
values |
Eigenvalues |
vectors |
Matrix with the eigenvectors. |
iter |
The number of iterations used in the eigendecomposition. |
li |
Projection of rows in the r principal components space. |
co |
Projection of columns in the r principal components space. |
Examples
data(iris)
X <- as.matrix(iris[,1:4])
rownames(X) <- iris[,5]
res <- calcPCA(X, r=3)
res$values
pcol <- c(rep("cyan",50), rep("red",50), rep("blue",50))
plot(res$li[,1], res$li[,3], col = pcol)