The PCOMP function computes the principal components of an m -column, n -row array, where m is the number of variables and n is the number of observations or samples. The principal components of a multivariate data set may be used to restate the data in terms of derived variables or may be used to reduce the dimensionality of the data by reducing the number of variables (columns). The result is an nvariables -column ( nvariables £ m ), n -row array of derived variables.
Use this keyword to specify a named variable that will contain the principal components used to compute the derived variables. The principal components are the coefficients of the derived variables and are returned in an m -column, m -row array. The rows of this array correspond to the coefficients of the derived variables. The coefficients are scaled so that the sums of their squares are equal to the eigenvalue from which they are computed. This keyword must be initialized to a nonzero value before calling PCOMP if the principal components are desired.
Set this keyword to compute the principal components using the covariances of the original data. The default is to use the correlations of the original data to compute the principal components.
Use this keyword to specify a named variable that will contain a one-column, m -row array of eigenvalues that correspond to the principal components. The eigenvalues are listed in descending order. This keyword must be initialized to a nonzero value before calling PCOMP if the eigenvalues are desired.
Use this keyword to specify the number of derived variables. A value of zero, negative values, and values in excess of the input array's column dimension result in a complete set ( m -columns and n -rows) of derived variables.
Define an array with 4 variables and 20 observations.
Compute the derived variables based upon the principal components. The COEFFICENTS, EIGENVALUES, and VARIANCES keywords must be initialized as nonzero values prior to calling PCOMP.
coefficients = 1 & eigenvalues = 1 & variances = 1
result = PCOMP(array, COEFFICIENTS = coefficients, $
EIGENVALUES = eigenvalues, VARIANCES = variances)
PRINT, result, FORMAT = '(4(f5.1, 2x))'
0.983668 0.947119 0.358085 0.925647
0.118704 -0.265644 0.932897 -0.215227
-0.134015 -0.179266 0.0378060 0.311214
-0.0185792 0.0161747 0.00707525 0.000456858
The first two derived variables account for 96.3% of the total variance of the original data.