Overload List
| # | Signature | Description |
|---|---|---|
| 1 | procedure PCA(const Data: TMtx; const PC: TMtx; const ZScores: TMtx; const EigenVec: TVec; const VarPct: TVec; const PCAMode: TPCAMode); | Perform a PCA on Data matrix, where Data columns are variables and rows are the observables. |
| 2 | procedure PCA(const CovMat: TMtx; const PC: TMtx; const EigenVec: TVec; const VarPct: TVec); | Performs a principal component analysis (PCA). |
Overload 1: procedure PCA(const Data: TMtx; const PC: TMtx; const ZScores: TMtx; const EigenVec: TVec; const VarPct: TVec; const PCAMode: TPCAMode);
Perform a PCA on Data matrix, where Data columns are variables and rows are the observables.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Data | TMtx | |
| 2 | PC | TMtx | |
| 3 | ZScores | TMtx | |
| 4 | EigenVec | TVec | |
| 5 | VarPct | TVec | |
| 6 | PCAMode | TPCAMode |
Result: stored in self (calling object)
The (optional) PCAMode parameter defines whether the analysis should be run on correlation or covariance matrix. PCA procedure returns the principal components in matrix PC, the Z-scores (data, transformed in the PC space) in ZScores, the eigenvalues of the covariance matrix (variances) in the EigenVec vector and (optional) the percentage of total variance in VarPct vector. The PC, ZScores, EigenVec and VarPct dimensions are adjusted automatically.
Uses Statistics, MtxExpr;
procecure Example;
var Data, PC: Matrix;
Variances,VarPercent : Vector;
begin
Data.SetIt(2,4,false,[1,3,5,2
2,5,7,9]);
PCA(data,PC,Variances,VarPercent,PCCovMat); //works on raw data
// ... Variances = [29,0,0,0]
// VarPercent = [100,0,0,0]
end;
Overload 2: procedure PCA(const CovMat: TMtx; const PC: TMtx; const EigenVec: TVec; const VarPct: TVec);
Performs a principal component analysis (PCA).
| # | Name | Type | Description |
|---|---|---|---|
| 1 | CovMat | TMtx | |
| 2 | PC | TMtx | |
| 3 | EigenVec | TVec | |
| 4 | VarPct | TVec |
Result: stored in self (calling object)
Perform a PCA by using the original data covariance matrix CovMat. Return the principal components in PC matrix, eigenvalues of the covariance matrix (variances) in vector EigenVec and (optional) the percentage of total variance in vector VarPct. The PC, EigenVec and VarPct dimensions are adjusted automatically.
Uses MtxExpr, Statistics;
procedure Example;
var Data, PC: Matrix;
Variances, ZS: Vector;
begin
Data.SetIt(2,4,false,[1,3,5,2,
2,5,7,9]);
Covariance(data,covMat,false);
PCA(covMat,PC,ZS,Variances); //requires cov matrix
// Z = [29 , 0, 0 ,0 ]
//variance = [100, 0, 0 ,0 ]
end;