public class PCAbyEigen
extends java.lang.Object
Each eigenvalue is proportional to the portion of the "variance" (more correctly of the sum of the squared distances of the points from their multidimensional mean) that is correlated with each eigenvector. The sum of all the eigenvalues is equal to the sum of the squared distances of the points from their multidimensional mean. PCA essentially rotates the set of points around their mean in order to align with the principal components. This moves as much of the variance as possible (using an orthogonal transformation) into the first few dimensions. The values in the remaining dimensions, therefore, tend to be small and may be dropped with minimal loss of information.
The R equivalent function is princomp. The main difference is that we use divisor (nObs - 1)
instead of nObs for the sample covariance matrix.
| Constructor and Description |
|---|
PCAbyEigen(Matrix data)
Perform a principal component analysis, using the eigen method and the preferred correlation matrix,
on a given data matrix.
|
PCAbyEigen(Matrix data,
boolean correlation)
Perform a principal component analysis, using the eigen method, on a given data matrix.
|
PCAbyEigen(Matrix data,
boolean correlation,
Matrix V)
Perform a principal component analysis, using the eigen method,
on a given data matrix with an optional correlation (or covariance) matrix provided.
|
| Modifier and Type | Method and Description |
|---|---|
Vector |
cumulativeProportionVar()
Get the cumulative proportion of overall variance explained by the principal components
|
ImmutableMatrix |
data()
Get the original data matrix.
|
Eigen |
eigen()
Get the eigenvalue decomposition of the correlation (or covariance) matrix.
|
Matrix |
loadings()
Get the matrix of variable loadings.
|
Vector |
loadings(int i)
Get the loading vector of the i-th principal component.
|
Vector |
mean()
Get the sample means that were subtracted.
|
int |
nFactors()
Get the number of variables in the original data.
|
int |
nObs()
Get the number of observations in the original data; sample size.
|
Vector |
proportionVar()
Get the proportion of overall variance explained by each of the principal components.
|
double |
proportionVar(int i)
Get the proportion of overall variance explained by the i-th principal component.
|
Vector |
scale()
Get the scalings applied to each variable.
|
Matrix |
scores()
Get the scores of supplied data on the principal components.
|
Vector |
sdPrincipalComponent()
Get the standard deviations of the principal components (i.e., the square roots of the eigenvalues of the covariance or correlation matrix).
|
double |
sdPrincipalComponent(int i)
Get the standard deviation of the i-th principal component.
|
Matrix |
V()
Get the correlation (or covariance) matrix used for the PCA.
|
Matrix |
X()
Get the (possibly centered and/or scaled) data matrix X used for the PCA.
|
public PCAbyEigen(Matrix data, boolean correlation, Matrix V)
data - an nObs*nFactors numeric matrix which provides the original data for the principal component analysiscorrelation - a logical value indicating whether the correlation matrix (preferred) or the covariance matrix should be used (N.B. the correlation matrix can only be used if there is no constant variable)V - an optional correlation (or covariance) matrix; if supplied, this is used rather than the correlation (or covariance) matrix of the centered (and possibly scaled) datapublic PCAbyEigen(Matrix data, boolean correlation)
data - a matrix which provides the original data for the principal component analysiscorrelation - a logical value indicating whether the correlation matrix (preferred) or the covariance matrix should be used
(N.B. the correlation matrix can only be used if there is no constant variable)public PCAbyEigen(Matrix data)
data - matrix which provides the original data for the principal component analysispublic Vector scale()
public Matrix V()
public Eigen eigen()
public Vector sdPrincipalComponent()
public Matrix loadings()
public Vector proportionVar()
proportionVar in interface PCApublic ImmutableMatrix data()
public int nObs()
PCApublic int nFactors()
PCApublic Vector mean()
PCApublic Matrix X()
PCApublic double sdPrincipalComponent(int i)
PCAsdPrincipalComponent in interface PCAi - an index, counting from 1public Vector loadings(int i)
PCApublic double proportionVar(int i)
PCAproportionVar in interface PCAi - an index, counting from 1public Vector cumulativeProportionVar()
PCAcumulativeProportionVar in interface PCA