PCOMP

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.

Calling Sequence

Result = PCOMP( A )

Arguments

A

An m -column, n -row, single- or double-precision floating-point array.

Keywords

COEFFICIENTS

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.

COVARIANCE

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.

DOUBLE

Set this keyword to force the computation to be done in double-precision arithmetic.

EIGENVALUES

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.

NVARIABLES

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.

STANDARDIZE

Set this keyword to convert the variables (the columns) of the input array to standardized variables (variables with a mean of zero and variance of one).

VARIANCES

Use this keyword to specify a named variable that will contain a one-column, m -row array of variances. The variances correspond to the percentage of the total variance for each derived variable.

Example

Define an array with 4 variables and 20 observations.

array = $

[[19.5, 43.1, 29.1, 11.9], $

[24.7, 49.8, 28.2, 22.8], $

[30.7, 51.9, 37.0, 18.7], $

[29.8, 54.3, 31.1, 20.1], $

[19.1, 42.2, 30.9, 12.9], $

[25.6, 53.9, 23.7, 21.7], $

[31.4, 58.5, 27.6, 27.1], $

[27.9, 52.1, 30.6, 25.4], $

[22.1, 49.9, 23.2, 21.3], $

[25.5, 53.5, 24.8, 19.3], $

[31.1, 56.6, 30.0, 25.4], $

[30.4, 56.7, 28.3, 27.2], $

[18.7, 46.5, 23.0, 11.7], $

[19.7, 44.2, 28.6, 17.8], $

[14.6, 42.7, 21.3, 12.8], $

[29.5, 54.4, 30.1, 23.9], $

[27.7, 55.3, 25.7, 22.6], $

[30.2, 58.6, 24.6, 25.4], $

[22.7, 48.2, 27.1, 14.8], $

[25.2, 51.0, 27.5, 21.1]]

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))'

IDL prints:

 81.4 15.5 -5.5 0.5

102.7 11.1 -4.1 0.6

109.9 20.3 -6.2 0.5

110.5 13.8 -6.3 0.6

 81.8 17.1 -4.9 0.6

104.8 6.2 -5.4 0.6

121.3 8.1 -5.2 0.6

111.3 12.6 -4.0 0.6

 97.0 6.4 -4.4 0.6

102.5 7.8 -6.1 0.6

118.5 11.2 -5.3 0.6

118.9 9.1 -4.7 0.6

 81.5 8.8 -6.3 0.6

 88.0 13.4 -3.9 0.6

 74.3 7.5 -4.8 0.6

113.4 12.0 -5.1 0.6

109.7 7.7 -5.6 0.6

117.5 5.5 -5.7 0.6

 91.4 12.0 -6.1 0.6

102.5 10.6 -4.9 0.6

PRINT, coefficients

IDL prints:

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

PRINT, eigenvalues

IDL prints:

2.84969

1.00128

0.148380

0.000657078

PRINT, variances

IDL prints:

0.712422

0.250319

0.0370950

0.000164269

The first two derived variables account for 96.3% of the total variance of the original data.

See Also

CORRELATE , EIGENQL