You are here: Symbol Reference > StatTools Namespace > Classes > TMtxPCA Class
Stats Master VCL
ContentsIndex
PreviousUpNext
TMtxPCA Class

Performs Principle Component Analysis (PCA).

StatTools_TMtxPCAStatTools_TMtxPCA
Pascal
TMtxPCA = class(TMtxComponent);

Principal Components Analysis - PCA - is a data analysis tool that is usually used to reduce the dimensionality (number of variables) of a large number of interrelated variables, while retaining as much of the information (variation) as possible. PCA calculates an uncorrelated set of variables (factors or PCs). These factors are ordered so that the first few retain most of the variation present in all of the original variables.  

 

The PCA procedure is reduced to an eigenvalue-eigenvector problem. PCA routines perform a PCA on either a correlation or a covariance matrix. Data matrix can be either "raw" data or pre-calculated correlation/covariance matrix. 

 

How to use TMtxPCA component?  

  1. Drop a TMtxPCA component on the form.
  2. By setting the crefPCAMode property define whether PCA will use correlation or covariance matrix to calculate PCA.
  3. Define the actual crefData (by changing Data matrix values).
  4. Call the crefRecalc method to calculate PCA results.

Results:

  1. crefEigValues - Data eigenvalues
  2. crefPC - Data eigenvectors
  3. crefTotalVarPct - the percentage of the total variation in the variables (columns)
  4. crefZScores - Z-Scores (eigenvectors in PC space).

An example how to setup TMtxPCA component:

Uses StatTools, MtxVec, Statistics;
procedure Example(MtxPCA1: TMtxPCA);
begin
  // ...
  MtxPCA1.Data.SetIt(4,3,false,[1,2,3,
                            5,7,9,
                            1,11,13,
                            3,7,4]);
  MtxPCA1.PCAMode := PCARawData; // using data matrix to evaluate PCA
  MtxPCA1.Recalc; // force recalculation
  // ...
end;
#include "StatTools.hpp"
#include "Statistics.hpp"
void __fastcall Example (TMtxPCA* MtxPCA1)
{
  // ...
  MtxPCA1->Data->SetIt(4,3,false,OPENARRAY(double,
                            (1,2,3,
                            5,7,9,
                            1,11,13,
                            3,7,4)));
  MtxPCA1->PCAMode = PCARawData; // using data matrix to evaluate PCA
  MtxPCA1->Recalc(); // trigger recalculation
  // ...
}
Examples on GitHub
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!