powered by
Given a data matrix, the function allows to perform principal component analysis using a power method to get the eigendecomposition.
calcPCA(X, r, eta, itmax, err, normed, mySeed)
This function returns a data frame containing 5 components
Eigenvalues
Matrix with the eigenvectors.
The number of iterations used in the eigendecomposition.
Projection of rows in the r principal components space.
Projection of columns in the r principal components space.
Data matrix of size (m,n), m >= n.
Number of principal components, default: r=2.
Power method tuning parameter, default: eta=10.
Maximum number of iteration in the power method, default: itmax=200.
Tolerance level in the power method, default: err=1e-8.
TRUE (default) or FALSE for PCA using standardized data or not.
An integer allowing to reproduce results from two different runs, default: mySeed=50.
X is usually a data matrix .
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)
Run the code above in your browser using DataLab